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
{{ message }}
Repository navigation
Commit 7e091e0
Browse filesBrowse the repository at this point in the historyBrowse files
"description": "This lesson was derived from Section 3.2 of <a href='http://www.diveintopython.net/native_data_types/lists.html'>Dive Into Python</a>.",
13
17
14
-
"1": "First, you define a list of five elements. Note that they retain their original order. This is not an accident. A list is an ordered set of elements enclosed in square brackets.",
18
+
"1": "First, you define a list of five elements. Note that after you execute this line, the elements retain their original order. This is not an accident. A list is an ordered set of elements enclosed in square brackets.",
15
19
16
20
"2": "You can get a subset of a list, called a \"slice\", by specifying two indices. The return value is a new list containing all the elements of the list, in order, starting with the first slice index (in this case <code>li[1]</code>), up to but not including the second slice index (in this case <code>li[3]</code>).",
17
21
@@ -21,8 +25,14 @@ li.extend(["two", "elements"])
21
25
22
26
"5": "<code>append</code> adds a single element to the end of the list.",
23
27
24
-
"6": "<code>insert</code> inserts a single element into a list. The numeric argument is the index of the first element that gets bumped out of position. Note that list elements do not need to be unique; there are now two separate elements with the value '<code>new</code>', <code>li[2]</code> and <code>li[6]</code>.",
28
+
"6": "<code>insert</code> inserts a single element into a list. The numeric argument is the index of the first element that gets bumped out of position. Note that list elements do not need to be unique; there will now be two separate elements with the value '<code>new</code>', <code>li[2]</code> and <code>li[6]</code>.",
25
29
26
-
"7": "<code>extend</code> concatenates lists. Note that you do not call <code>extend</code> with multiple arguments; you call it with one argument, a list. In this case, that list has two elements."
30
+
"7": "<code>extend</code> concatenates lists. Note that you do not call <code>extend</code> with multiple arguments; you call it with one argument, a list. In this case, that list has two elements.",
31
+
32
+
"8": "<code>remove</code> removes the first occurrence of a value from a list.",
33
+
34
+
"9": "<code>remove</code> removes <i>only</i> the first occurrence of a value. In this case, '<code>new</code>' appears twice in the list, but <code>li.remove(\"new\")</code> will remove only the first occurrence.",
35
+
36
+
"11": "If the value is not found in the list, Python raises an exception. This mirrors the behavior of the <code>index</code> method."
0 commit comments