0
What is essential for understanding string looping?
3 Respuestas
0
How can I learn about string looping?
0
In which language..? Did lesson is not helpful? What is difficultly there?
https://www.sololearn.com/discuss/333866/?ref=app
0
Hi! To travers a string with Python as an example language:
Use the fact that every position in an string has an index:
>>> s = "abc"
>>> for i in range(len(s)): print(s[i])
…
a
b
c
Or use the iteration protocol:
>>> s = "abc"
>>> for c in s: print(c)
…
a
b
c
You can even use a while loop in the same way:
>>> s = "abc"
>>> i = 0
>>> while i < 3:
… print(s[i])
… i += 1
…
a
b
c