Use the for-loop and enumerate function to print the index of the character in a string.
Python program to print the index of the character in a string Example
Simple example code.
str1 = "PYTHON" for index, char in enumerate(str1): print(char, "position at", index)
Do comment if you have any doubts and suggestions on this python index char topic
Note: IDE: PyCharm 2021.3.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.