In Python, while operating with String, one can do multiple operations on it. Let’s see how to iterate over characters of a string in Python.
Example #1: Using simple iteration and
g e e k s f o r g e e k s G E E K S
Example #2: Using
G e e k s
Example #3: Iterate characters in reverse order
S K E E G s k e e g r o f s k e e g
Example #4: Iteration over particular set of element.
Perform iteration over string_name by passing particular string index values.
g e e k s f o r
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course