>>> item_count = { "a":3, "b":2, "c":1 }
>>> for idx, (val, cnt) in enumerate(item_count.iteritems(), 1):
print (f"{idx}th | {val} is {cnt})
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
for idx, (val, cnt) in enumerate(item_count.iteritems(), 1):
AttributeError: 'dict' object has no attribute 'iteritems'
>>> for idx, (val, cnt) in enumerate(item_count.items(), 1):
print (f"{idx}th | {val} is {cnt})
1st | a has 3
2nd | 2 for b
3rd | c is 1
© 2024 OneMinuteCode. All rights reserved.