It is a method in python that iterates through the string, adds a counter to it and returns an object. The object can be converted to list or tuple later.
Syntax:
enumerate(iterable, starting_position)
Example 1:
s = “Code,eat,repeat” x = enumerate(s) print(x) print(list(x))
Here it returned an object, which is later converted to list. Each character of the string is iterated (‘C’, ‘o’, ‘d’ ….) and returned with a counter (0, 1, 2, 3..) inside the list as pairs.
Example 2:
s = “Code eat repeat” x = enumerate(s) print(x) print(tuple(x))