This post will discuss how to iterate over each character in a string in Python.

1. Using for-loop

A simple solution is to use the loop construct to print characters in the string.

Download  Run Code

2. Using enumerate() function

The Pythonic solution to iterate over each character in a string along with an index is using the built-in function enumerate().

Download  Run Code

3. Using range() function

Another option to iterate over the string with indexes can be done using the range() and len().

Download  Run Code

That’s all about iterating over each character in a string in Python.