Using the Python enumerate function in the string, you can loop over it and will get value with the index. The Enumerate() command adds a counter to each item of the iterable object and returns an enumerate object as an output string.
Enumerate allows you to loop through a list, tuple, dictionary, string, and gives the values along with the index.
Python enumerate string
Simple example code Iterating each character in a string using Python.
my_str = "HELLO" for i in enumerate(my_str): print(i)
Output: the result will show you the index and value for each character of the string.
Do comment if you have any doubts and suggestions on this Python enumerate topic.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.