use enumerate for for loop to get index and element

PHOTO EMBED

Wed Feb 28 2024 06:57:25 GMT+0000 (Coordinated Universal Time)

Saved by @viperthapa #python

cities = ['New York', 'Beijing', 'Cairo', 'Mumbai', 'Mexico']

for item in enumerate(cities):
    print(item)
Code language: Python (python)
content_copyCOPY

https://www.pythontutorial.net/python-basics/python-for-loop-list/