0

What is essential for understanding string looping?

29th Mar 2022, 6:21 PM
Shar Kim
3 Respuestas
0
How can I learn about string looping?
29th Mar 2022, 6:21 PM
Shar Kim
0
In which language..? Did lesson is not helpful? What is difficultly there? https://www.sololearn.com/discuss/333866/?ref=app
29th Mar 2022, 6:39 PM
Jayakrishna 🇮🇳
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
29th Mar 2022, 6:48 PM
Per Bratthammar
Per Bratthammar - avatar