☞It can be done in two ways :
1. Using Index 2. Without Using Index
☞ Using Index
Example 1 :
#Traversing a string using for loop
S = "PYTHON"
for i in range(len(S)):
print(S[i])
P Y T H O N
#Traversing a string using while loop
S = "PYTHON"
i = 0
while i < len(S):
print(S[i])
i = i + 1
P Y T H O N
☞ Without Using Index
Example :S = "PYTHON" for i in S: print(i)
P Y T H O N