enumerate() in Python String

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)) Output: [(0, ‘C’), (1, ‘o’), (2, ‘d’), (3, ‘e’), (4, ‘,’), (5, ‘e’), (6, ‘a’), […]

enumerate() in Python String Read More »