#enumerate()๋ '์ด๊ฑฐํ๋ค'๋ ๋ป์ ํจ์๋ก,
#์ฌ๋ฌ๊ฐ์ง ์๋ฃํ(list, tuple, set๋ฑ)์
#์ธ๋ฑ์ค๋ฅผ ํฌํจํ enumerate ๊ฐ์ฒด๋ก return
#list์ฌ์ฉ
a = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
for idx, val in enumerate(a):
print(idx, val)
#์ถ๋ ฅ
#0 10
#1 9
#2 8
#3 7
#4 6
#5 5
#6 4
#7 3
#8 2
#9 1
#tuple์ฌ์ฉ
b = (2, 5, 6)
for idx, val in enumerate(b):
print(idx, val)
#์ถ๋ ฅ
#0 2
#1 5
#2 6
#enumerate๊ฐ์ฒด๋ฅผ listํ์
์ผ๋ก ๋ณํํ๋ ๊ฒฝ์ฐ
letters = ['a', 'b', 'c', 'd']
print(list(enumerate(letters)))
#์ถ๋ ฅ
#[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd')]
#์์๊ฐ์ ์ง์ ํ ์ ์์
#default๊ฐ์ 0
#์์๊ฐ๋ถํฐ 1์ฉ ์ฆ๊ฐ
a = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
for idx, val in enumerate(a, start = 1):
print(idx, val)
#์ถ๋ ฅ
#1 10
#2 9
#3 8
#4 7
#5 6
#6 5
#7 4
#8 3
#9 2
#10 1
b = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
for idx, val in enumerate(b, start = 3):
print(idx, val)
#์ถ๋ ฅ
#3 10
#4 9
#5 8
#6 7
#7 6
#8 5
#9 4
#10 3
#11 2
#12 1