enumerate() in Python

What is enumerate ?

Enumerate() method adds a counter to an iterable and returns it in a form of enumerate object. This enumerate object can then be used directly in for loops or be converted into a list of tuples using list() method.

list1 = []
n = 10
for items in range(n):
    a = int(input("Enter your items : "))
    list1.append(a)
print(list1)
for e, items in enumerate(list1):
    print(f"The index is {e} and the value of index is {items}")

Leave a comment