summaryrefslogtreecommitdiffhomepage
path: root/python.html.markdown
diff options
context:
space:
mode:
authormrshankly <mrshankly@riseup.net>2013-06-28 21:29:03 +0100
committermrshankly <mrshankly@riseup.net>2013-06-28 21:29:03 +0100
commitf7352567f4f76a26ebfe09365faa8bc790463dd3 (patch)
treeaf329e2c58028d9e108d5ace26eb683a16b8c69e /python.html.markdown
parent2e805c8c020719da0aab40987b7c064c864db9c8 (diff)
Corrected the last element of li in the lists explanation.
Diffstat (limited to 'python.html.markdown')
-rw-r--r--python.html.markdown8
1 files changed, 4 insertions, 4 deletions
diff --git a/python.html.markdown b/python.html.markdown
index 39a2349d..0d9a3ed6 100644
--- a/python.html.markdown
+++ b/python.html.markdown
@@ -122,7 +122,7 @@ li.append(3) # li is now [1, 2, 4, 3] again.
# Access a list like you would any array
li[0] #=> 1
# Look at the last element
-li[-1] #=> 4
+li[-1] #=> 3
# Looking out of bounds is an IndexError
try:
@@ -145,7 +145,7 @@ del li[2] # li is now [1, 2, 3]
li + other_li #=> [1, 2, 3, 4, 5, 6] - Note: li and other_li is left alone
# Concatenate lists with extend
-li.extend(other_li) # Now li is [1, 2, 3, 4, 5, 6]
+li.extend(other_li) # Now li is [1, 2, 3, 4, 5, 6]
# Check for existence in a list with in
1 in li #=> True
@@ -255,14 +255,14 @@ prints:
"""
for animal in ["dog", "cat", "mouse"]:
# You can use % to interpolate formatted strings
- print "%s is a mammal" % animal
+ print "%s is a mammal" % animal
"""
While loops go until a condition is no longer met.
prints:
0
1
- 2
+ 2
3
"""
x = 0