티스토리 뷰

공부

[Python] for get index

seunggabi 승가비 2020. 8. 5. 02:43
seasons = ['Spring', 'Summer', 'Fall', 'Winter']

list(enumerate(seasons))
[(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]



for idx, val in enumerate(seasons):
    print(idx, val)

0 Spring
1 Summer
2 Fall
3 Winter

https://www.daleseo.com/python-enumerate/

 

[파이썬] for 루프에서 인덱스 얻기

Engineering Blog by Dale Seo

www.daleseo.com

 

댓글
댓글쓰기 폼