If storedlist
is a dictionary, then looping over the dictionary with for i in storedlist
will set i
to the keys of the dictionary. If you want to print the values instead, iterate over the values specifically with:
for i in storedlist.values():
print(i)
To get both the keys and the values, use:
for key, value in storedlist.items():
print "{} --> {}".format(key, value)
Here, items()
gives you the keys and values in a tuple, which can be directly unpacked into two separate variables (key
and value
above).
Also, if the dictionary has many items, it may be more efficient for you to use itervalues()
or iteritems()
to generate the values in the loop without fully building a list as described further here.