error ‘list index is out of range’
my code is exactly as per given solution, but it is giving error : "list index is out of range"
code:
company_names = ['Python DS', 'PythonSoft', 'Pythazon' 'Pybook']
key_name = ['open', 'high', 'low', 'close']
prices = [[12.87, 13.23, 11.42, 13.10],[23.54, 25.76, 21.87, 22.33],[98.99, 102.34, 97.21, 100.065],[203.63, 207.54, 202.43, 205.24]]
d_1 = {}
for i in range(len(key_name)):
d_1[company_names[i]]= dict(zip(key_name,prices[i]))
print (d_1)
not getting why eroor is occuring.
1 answers ( 0 marked as helpful)
Hi Sumeera,
thanks for reaching out and sorry for the delayed responce!
One possible reason might be that there appears to a ',' missing between 'Pythazon' and 'Pybook' in your company_names list.
Annoyingly, that's the sort of thing that's extremely easy to miss by humans, but the compiler usually has something against.
In any case, if there are any further issues, let us know.
Best,
365 Eli