Skip to content

Commit 406e97b

Browse files
committed
Update strings chapter
1 parent 97ad5ef commit 406e97b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/strings.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@ Now if you want to multiline strings you have to use triple single/double quotes
3434
multiline string, so you can
3535
write many lines
3636

37+
38+
We can have two string literals side by side, and it will behave like a single string. For example
39+
40+
::
41+
42+
>>> s = "Hello " "World"
43+
>>> print(s)
44+
Hello World
45+
46+
This will help you to spilt a long string into smaller chunks in function calls.
47+
48+
49+
You can find length of any string using the `len` function call.
50+
51+
::
52+
53+
>>> s = "Python"
54+
>>> len(s)
55+
6
56+
57+
3758
Different methods available for Strings
3859
=======================================
3960

@@ -207,3 +228,20 @@ The output
207228
The number of words in the line are 5
208229

209230

231+
Iterating over all characters of a string
232+
==========================================
233+
234+
You can iterate over a string using simple `for` loop.
235+
236+
::
237+
238+
>>> for ch in "Python":
239+
... print(ch)
240+
...
241+
P
242+
y
243+
t
244+
h
245+
o
246+
n
247+

0 commit comments

Comments
 (0)