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)
Output:
![Python program to print index of character in string](https://i0.wp.com/tutorial.eyehunts.com/wp-content/uploads/2021/08/Python-program-to-print-index-of-character-in-string.jpg?resize=303%2C261&ssl=1)
Do comment if you have any doubts and suggestions on this python index char topic
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.