Case 1
a = ['A', 'B', 'C']
for i in range(len(a)):
print(i, a[i])
0 A
1 B
2 C
Case 2
a = ['A', 'B', 'C']
for i, v in enumerate(a):
print(i, v)
0 A
1 B
2 C
Case 3 (Not Recommended)
a = ['A', 'B', 'C']
for i in a:
print(a.index(i), i)
0 A
1 B
2 C
Case 4 (Not Recommended)
a = ['A', 'B', 'C', 'A']
for i in a:
print(a.index(i), i)
0 A
1 B
2 C
0 A
댓글 없음:
댓글 쓰기