In this post we will be creating a Python script that will iterate a string by character. This will enable us to get each character from the string, one at a time.
To do this we will use a for loop which will enable us to iterate the string, see the snippet of code below for how this is done. In this example our string is seen as ‘Hello World!’.
string="Hello World!"
for character in string:
print(character)
The above would return the following as output.
H
e
l
l
o
W
o
r
l
d
!
>>>
Take a look at some of our other content around the Python programming language by clicking here.