0
What is essential for understanding string looping?
3 Answers
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