0

What is essential for understanding string looping?

29th Mar 2022, 6:21 PM
Shar Kim
3 Answers
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