🛠️ Scheduled Maintenance | We’ll be undergoing scheduled maintenance and upgrades between 00:00 PST Jan 26th until 00:00 PST Jan 28th. There may be brief interruption of services in that period. We apologize for the inconvenience.

The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Anybody can ask a question
Anybody can answer
The best answers are voted up and moderated by our team

error ‘list index is out of range’

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”


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 Answer

365 Team

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.
365 Eli

Thank you so much Eli, the problem solved.

1 month