@@ -148,11 +148,12 @@ Indexing with negative values works like this:
148148
149149## String methods
150150
151- Python's strings have many useful methods. [ The official documentation]
152- (https://docs.python.org/3/library/stdtypes.html#string-methods ) covers
153- them all, but I'm going to just show some of the most commonly used ones
154- briefly. Python also comes with built-in documentation about the string
155- methods and we can run ` help(str) ` to read it.
151+ Python's strings have many useful methods.
152+ [ The official documentation] ( https://docs.python.org/3/library/stdtypes.html#string-methods )
153+ covers them all, but I'm going to just show some of the most commonly
154+ used ones briefly. Python also comes with built-in documentation about
155+ the string methods and we can run ` help(str) ` to read it. You can also
156+ get help about one string method at a time, like ` help(str.upper) ` .
156157
157158Again, nothing can modify strings in-place. Most string methods
158159return a new string, but things like ` our_string = our_string.upper() `
179180False
180181>> > our_string.replace(' World' , ' there' )
181182' Hello there!'
182- >> > our_string.replace(' l ' , ' ł ' , 1 ) # only replace one l
183- ' Hełlo World!'
183+ >> > our_string.replace(' o ' , ' @ ' , 1 ) # only replace one o
184+ ' Hell@ World!'
184185>> > ' hello 123 ' .lstrip() # left strip
185186' hello 123 '
186187>> > ' hello 123 ' .rstrip() # right strip
0 commit comments