author | Puneeth Chaganti <punchagan@fossee.in> |
Thu, 11 Nov 2010 10:37:26 +0530 | |
changeset 465 | 78d20cd87c7e |
parent 285 | 7c4855fb8e5f |
permissions | -rw-r--r-- |
285 | 1 |
\textbf{Manipulating strings} |
2 |
||
3 |
String indexing starts from 0, like lists. |
|
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
4 |
|
285 | 5 |
\lstinline|s = `Hello World'|\\ |
6 |
\lstinline|s[0:5]| gives \texttt{Hello}\\ |
|
7 |
\lstinline|s[6:]| gives \textt{World}\\ |
|
8 |
\lstinline|s[6::2]| gives \textt{Wrd}\\ |
|
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
9 |
|
285 | 10 |
\lstinline|s.replace('e', 'a')| returns a new string with all e's |
11 |
replaced by a. |
|
12 |
||
13 |
\lstinline|s.lower()| and \lstinline|s.upper()| return new strings |
|
14 |
with all lower and upper case letters, respectively. |