manipulating-strings.rst
author Nishanth Amuluru <nishanth@fossee.in>
Wed, 06 Oct 2010 14:45:59 +0530
changeset 214 8b08fc88d5a0
parent 144 476ea1730aee
permissions -rw-r--r--
Added questions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
144
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     1
========
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     2
 Script
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     3
========
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     4
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     5
{{{ show the welcome slide }}}
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     6
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     7
Welcome to this tutorial on manipulating strings. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     8
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
     9
{{{ show the slide with outline }}} 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    10
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    11
In this tutorial we shall learn to manipulate strings, specifically
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    12
slicing and reversing them, or replacing characters, converting from
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    13
upper to lower case and vice-versa 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    14
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    15
#[punch: reversed returns an iterator. should we still teach it?]
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    16
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    17
We have an ``ipython`` shell open, in which we are going to work,
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    18
through out this session. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    19
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    20
Let us consider a simple problem, and learn how to slice strings and
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    21
get sub-strings. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    22
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    23
Let's say the variable ``week`` has the list of the names of the days
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    24
of the week. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    25
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    26
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    27
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    28
    week = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    29
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    30
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    31
Now given a string ``s``, we should be able to check if the string is a
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    32
valid name of a day of the week or not. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    33
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    34
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    35
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    36
    s = saturday
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    37
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    38
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    39
``s`` could be in any of the forms --- sat, saturday, Sat, Saturday,
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    40
SAT, SATURDAY. We shall now be solving the problem only for the forms,
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    41
sat and saturday. We shall solve it for the other forms, at the end of
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    42
the tutorial. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    43
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    44
{{{ show these forms in a slide }}}
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    45
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    46
So, we need to check if the first three characters of the given string
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    47
exists in the variable ``week``. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    48
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    49
As, with any of the string data-types, strings can be sliced into
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    50
sub-strings. To get the first three characters of s, we say, 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    51
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    52
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    53
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    54
    s[0:3]
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    55
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    56
Note that, we are slicing the string from the index 0 to index 3, 3
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    57
not included. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    58
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    59
As we already know, the last element of the string can be accessed
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    60
using ``s[-1]``.  
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    61
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    62
%%1%% Pause the video here and obtain the sub-string excluding the
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    63
first and last characters from the string. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    64
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    65
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    66
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    67
    s[1:-1]
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    68
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    69
gives the a substring of s, without the first and the last
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    70
characters. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    71
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    72
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    73
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    74
    s = saturday
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    75
    s[:3]
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    76
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    77
Now, we just check if that substring is present in the variable
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    78
``week``. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    79
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    80
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    81
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    82
    s[:3] in week          
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    83
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    84
Let us now consider the problem of finding out if a given string is
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    85
palindromic or not. First of all, a palindromic string is a string
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    86
that remains same even when it has been reversed.
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    87
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    88
Let the string given be ``malayalam``.
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    89
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    90
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    91
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    92
    s = "malayalam"
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    93
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    94
Now, we need to compare this string with it's reverse. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    95
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    96
Again, we will use a technique common to all sequence data-types,
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    97
[::-1]
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    98
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
    99
So, we obtain the reverse of s, by simply saying, 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   100
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   101
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   102
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   103
    s[::-1]
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   104
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   105
Now, to check if the string is ``s`` is palindromic, we say
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   106
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   107
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   108
    s == s[::-1]
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   109
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   110
As, expected, we get ``True``. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   111
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   112
Now, if the string we are given is ``Malayalam`` instead of
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   113
``malayalam``, the above comparison would return a False. So, we will
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   114
have to convert the string to all lower case or all upper case, before
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   115
comparing. Python provides methods, ``s.lower`` and ``s.upper`` to
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   116
achieve this. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   117
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   118
Let's try it out. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   119
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   120
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   121
   s = "Malayalam"
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   122
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   123
   s.upper()
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   124
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   125
   s
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   126
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   127
   s.lower()
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   128
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   129
   s.lower() == s.lower()[::-1]
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   130
   
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   131
Note that these methods, do not change the original string, but return
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   132
a new string.
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   133
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   134
a%% %% Pause the video here, and finish the problem of checking if
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   135
``s`` is a valid name of a day of the week and then resume the
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   136
video. Change the solution to this problem, to include forms like,
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   137
SAT, SATURDAY, Saturday and Sat. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   138
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   139
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   140
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   141
    s.lower()[:3] in week
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   142
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   143
We just convert any input string to lower case and then check if it is
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   144
present in the list ``week``. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   145
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   146
Now, let us consider another problem. We often encounter e-mail id's
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   147
which have @ and periods replaced with text, something like
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   148
info[at]fossee[dot]in. We now wish to get back proper e-mail
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   149
addresses.  
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   150
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   151
Let's say the variable email has the email address. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   152
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   153
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   154
   email = "info[at]fossee[dot]in"
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   155
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   156
Now, we first replace the ``[at]`` with the ``@``, using the replace
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   157
method of strings. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   158
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   159
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   160
   email = email.replace("[at]", "@")
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   161
   print email
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   162
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   163
%%1%% Pause the video here and replace the ``[dot]`` with ``.`` and then
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   164
resume the video. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   165
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   166
::
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   167
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   168
   email = email.replace("[dot]", ".")        
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   169
   print email
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   170
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   171
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   172
That brings us to the end of the tutorial. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   173
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   174
{{{ show summary slide }}}
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   175
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   176
In this tutorial, we have learnt how to get substrings, reverse
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   177
strings and a few useful methods, namely upper, lower and replace. 
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   178
476ea1730aee Added rst files for scripts.
Puneeth Chaganti <punchagan@gmail.com>
parents:
diff changeset
   179
Thank You!