Traversing a string means accessing all the elements of the string one after the other by using the subscript. A string can be traversed using for loop or while loop.
For example :
A = ‘Python’
i = 0
while i < lenn (A) :
print A[i]
i = i + 1
Output :
P
y
t
h
o
n