in this example we'll learn how to print each character in a string

syntax

1
2
for i in your_string:
      print(i)

example

1
2
3
4
5
6
7
#string
string = "my name is mark"

#loop
for i in string:
    #print each character
    print(i)

output

m                                                                                                                                     
y                                                                                                                                     

n                                                                                                                                     
a                                                                                                                                     
m                                                                                                                                     
e 

i
s 

m                                                                                                                                     
a                                                                                                                                     
r                                                                                                                                     
k   

example 2 : print each characters without spaces

probably you don't wanna print spaces with characters. so in this example we'll remove spaces from characters

to do that we need use replace() function, with this function we'll remove spaces in the string

syntax

1
string.replace(" ", "")

example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#string
string = "my name is mark"

#remove spaces
new_string = string.replace(" ", "")

#loop
for i in new_string:
    #print each character
    print(i)
    

output

m                                                                                                                                      
y                                                                                                                                      
n                                                                                                                                      
a                                                                                                                                      
m                                                                                                                                      
e                                                                                                                                      
i                                                                                                                                      
s                                                                                                                                      
m                                                                                                                                      
a                                                                                                                                      
r                                                                                                                                      
k  

English today is not an art to be mastered it's just a tool to use to get a result