+1 vote
in Class 11 by kratos

What do you understand by traversing a string ?

1 Answer

+6 votes
by kratos
 
Best answer

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

...