How to print key value in python for in
漂亮男人
漂亮男人 2017-06-12 09:22:57
0
3
780
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

漂亮男人
漂亮男人

reply all(3)
typecho
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)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!