a=[1,0,1,0] for i in a: print i
This can print 1, 0, 1, 0. I want to print his array key value 0,1,2,3. How to do it
a=[1,0,1,0] for i, v in enumerate(a): print i, v
a=[1,0,1,0] for index,value in enumerate(a): print index
Line number output (line number starts from 1)
my_list = ['a', 'b', 'c'] for idx, val in enumerate(my_list, 1): print(idx, val)
Line number output (line number starts from 1)