📜  在 python 代码示例中枚举

📅  最后修改于: 2022-03-11 14:45:37.592000             🧑  作者: Mango

代码示例6
list1 = ['1', '2', '3', '4']

for index, listElement in enumerate(list1): 
    #What enumerate does is, it gives you the index as well as the element in an iterable
    print(f'{listElement} is at index {index}') # This print statement is just for example output

# This code will give output : 
"""
1 is at index 0
2 is at index 1
3 is at index 2
4 is at index 3
"""