diff options
Diffstat (limited to 'manipulating_strings/quickref.tex')
-rw-r--r-- | manipulating_strings/quickref.tex | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/manipulating_strings/quickref.tex b/manipulating_strings/quickref.tex new file mode 100644 index 0000000..533a1ef --- /dev/null +++ b/manipulating_strings/quickref.tex @@ -0,0 +1,14 @@ +\textbf{Manipulating strings} + +String indexing starts from 0, like lists. + +\lstinline|s = `Hello World'|\\ +\lstinline|s[0:5]| gives \texttt{Hello}\\ +\lstinline|s[6:]| gives \textt{World}\\ +\lstinline|s[6::2]| gives \textt{Wrd}\\ + +\lstinline|s.replace('e', 'a')| returns a new string with all e's +replaced by a. + +\lstinline|s.lower()| and \lstinline|s.upper()| return new strings +with all lower and upper case letters, respectively. |