1items=['baseball','basketball','football']
2for index, item in enumerate(items):
3 print(index, item)
1for index, item in enumerate(items):
2 print(index, item)
3
4#if you want to start from 1 instead of 0
5for count, item in enumerate(items, start=1):
6 print(count, item)
1my_list = [0,1,2,3,4]
2for idx, val in enumerate(my_list):
3 print('{0}: {1}'.format(idx,val))
4#This will print:
5#0: 0
6#1: 1
7#2: 2
8#...
1colors = ["red", "green", "blue", "purple"]
2
3for i in range(len(colors)):
4 print(colors[i])
5
1colors = ["red", "green", "blue", "purple"]
2for i in range(len(colors)):
3 print(colors[i])
4