by @saigowthamr

How to iterate through a String in Python

Home » python » How to iterate through a String in Python

To iterate over a each character in a string we can use for loop in Python.

Here is an example that iterates over a string cabinet.

for char in "cabinet":
    print(char)

Output:

c
a
b
i
n
e
t

Best Web Development courses