python-enumerate() 函数的用法

seasons = ['Spring', 'Summer', 'Fall', 'Winter']
print(list(enumerate(seasons)))
for i,value in enumerate(seasons):
    print(i,value)


输出结果:
[(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]
0 Spring
1 Summer
2 Fall
3 Winter

 

posted @ 2020-03-22 22:31  爱打盹的猫猫  阅读(175)  评论(0编辑  收藏  举报