How to Loop Through a String in Python


In this example, we will learn how to loop through a string in Python.

Source Code

str = 'abcd'
for x in str:
    print(x)

Output:

a
b
c
d
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments