summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Sethi2010-11-11 12:19:32 +0530
committerAmit Sethi2010-11-11 12:19:32 +0530
commit506a76194b487be1a32c486dc8f6b5c9e8652546 (patch)
tree451b9eafbe1c19b65d35a772dd262d9edf72f28e
parent83dec2ea5d85b338dccd6956f3e3d24367d6244f (diff)
downloadst-scripts-506a76194b487be1a32c486dc8f6b5c9e8652546.tar.gz
st-scripts-506a76194b487be1a32c486dc8f6b5c9e8652546.tar.bz2
st-scripts-506a76194b487be1a32c486dc8f6b5c9e8652546.zip
Changes in getting started with list. Elaborating some points as suggested in review
-rw-r--r--getting-started-with-lists/script.rst17
1 files changed, 16 insertions, 1 deletions
diff --git a/getting-started-with-lists/script.rst b/getting-started-with-lists/script.rst
index 61271e4..4e11d0a 100644
--- a/getting-started-with-lists/script.rst
+++ b/getting-started-with-lists/script.rst
@@ -153,7 +153,7 @@ There are two ways of doing it. One is by using index. ::
deletes the element at index 1, i.e the second element of the
list, 'eggs'. The other way is removing element by content. Lets say
one wishes to delete 100 from nonempty list the syntax of the command
-should be
+would be
.. #[[Anoop: let x = [1,2,1,3]
now x.remove(x[2])
@@ -178,6 +178,21 @@ If we check now we will see that the first occurence 'spam' is removed
thus remove removes the first occurence of the element in the sequence
and leaves others untouched.
+One should remember this that while del removes by index number.
+Remove , removes on the basis of content being passed so if ::
+
+ k = [1,2,1,3]
+ del([k[2])
+
+gives us [1,2,3]. ::
+
+ k.remove(x[2])
+
+will give us [2,1,3]. Since it deletes the first occurence of what is
+returned by x[2] which is 1.
+
+
+