I want to print the following dictionary line by line where the second line should be the list itself (in Python 2x):
dict = {1: [10, 20, 30], 2: [40, 50]}
for i in dict:
print ("i = %s" % i)
for j in dict[i]:
print dict[i][j]
print ("\n")
This is by following this answer but still having this error that said out of range!!
i = 1
Traceback (most recent call last):
File "./t.py", line 26, in <module>
print dict[i][j]
IndexError: list index out of range
I am learning Python by myself. I apologize if this question is trivial to most of you.