You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of my students last night got confused with the tutorial where we
weren't directly calling `print()` and yet stuff was appearing on the
screen. She wasn't sure if simply typing out the variable was somehow
*doing* something. Using `print()` explicitly everywhere should clear
this up.
Similarly, `>>> ` was only being used in parts of the document, leaving
it unclear as to whether this is something that needs to be typed, or if
perhaps the absence of it meant they weren't in the REPL.
This commit addressed both issues.
Copy file name to clipboardExpand all lines: python/lesson3/tutorial.md
+42-40Lines changed: 42 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,18 +39,18 @@ which is where most people would expect things to start. This means that the
39
39
*first* element of a list is referred to with a `0`, the second element is
40
40
referred to with a `1`, and so on. Perhaps an example would be helpful:
41
41
42
-
>>> places_to_visit[0]
42
+
>>> print(places_to_visit[0])
43
43
'Mexico'
44
-
>>> places_to_visit[2]
44
+
>>> print(places_to_visit[2])
45
45
'Kenya'
46
46
47
47
Positive numbers aren't the only thing you can use for indexes though. Negative
48
48
numbers invert the index, so you can get the *last* element of a list by using
49
49
`-1`, or the third-to-last by using `-3`:
50
50
51
-
>>> places_to_visit[-1]
51
+
>>> print(places_to_visit[-1])
52
52
'New Zealand'
53
-
>>> places_to_visit[-3]
53
+
>>> print(places_to_visit[-3])
54
54
'Kenya'
55
55
56
56
Try it yourself now: Try to get `Nepal` out of `places_to_visit` using both a
@@ -71,23 +71,23 @@ There's a lot that you can do with lists, so much that we simply can't cover it
71
71
all here, so instead here are some examples, and a [link to the documentation](https://docs.python.org/3.5/tutorial/datastructures.html#more-on-lists"Methods of lists")
0 commit comments