manipulating-strings/script.rst
changeset 381 5415cb1bb4af
parent 350 d14bc84feca1
child 454 0c69c2b32183
--- a/manipulating-strings/script.rst	Fri Nov 05 21:19:11 2010 +0530
+++ b/manipulating-strings/script.rst	Fri Nov 05 21:42:20 2010 +0530
@@ -34,9 +34,6 @@
 slicing and reversing them, or replacing characters, converting from
 upper to lower case and vice-versa and joining a list of strings.
 
-.. #[punch: reversed returns an iterator. should we still teach it?]
-
-
 We have an ``ipython`` shell open, in which we are going to work,
 through out this session. 
 
@@ -69,9 +66,8 @@
 So, we need to check if the first three characters of the given string
 exists in the variable ``week``. 
 
-As, with any of the string data-types, strings can be sliced into
-.. #[Amit: Sequence data type???]
-sub-strings. To get the first three characters of s, we say, 
+As, with any of the sequence data-types, strings can be sliced into
+sub-strings. To get the first three characters of s, we say,
 
 ::
 
@@ -84,7 +80,7 @@
 using ``s[-1]``.  
 
 Following is an exercise that you must do. 
-.. #[Amit: I don't know I am not sure about the sentence formation.]
+
 %%1%% Obtain the sub-string excluding the first and last characters
 from the string s. 
 
@@ -129,7 +125,7 @@
 ::
 
     s[::-1]
-.. #[amit: I think using reversed in not required after this]
+
 Now, to check if the string is ``s`` is palindromic, we say
 ::
 
@@ -152,16 +148,15 @@
 
    s
 
+As you can see, s has not changed. It is because, ``upper`` returns a
+new string. It doesn't change the original string. 
+
+::
+
    s.lower()
 
    s.lower() == s.lower()[::-1]
    
-Note that these methods, do not change the original string, but return
-a new string.
-
-.. #[amit: I wish we could include this right when s.upper() is used so 
-.. that it is clear]
-
 Following is an exercise that you must do. 
 
 %%2%% Check if ``s`` is a valid name of a day of the week. Change the
@@ -176,8 +171,11 @@
 
     s.lower()[:3] in week
 
-.. #[amit: May be a sentence or two about what our original problem was and 
-.. how this helps in solving it. One can loose the flow.]
+
+So, as you can see, now we can check for presence of ``s`` in
+``week``, in whichever format it is present -- capitalized, or all
+caps, full name or short form.
+
 We just convert any input string to lower case and then check if it is
 present in the list ``week``.