👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.
How to iterate over string with index in Python?
The best way to iterate over string with index is to convert the string to an enumerate object:
>>> str = "Hello!"
>>> for index, char in enumerate(str):
>>> print (index, ' => ' , char)
0 => H
1 => e
2 => l
3 => l
4 => o
5 => !