The operation of enumerate was interesting, so I will describe it.
enumerate is very useful when putting a dictionary into a for statement.
python
d = {5:1, 6:2, 7:3}
Put the above dictionary in the for statement.
python
for i, x in enumerate(d):
print(i,x)
#0 5
1 6
2 7
If you execute enumerate from the above i has a sequence number x has a key enter.
Recommended Posts