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
Copy file name to clipboardExpand all lines: concepts/lists/about.md
+13-9
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Accessing elements, checking for membership via `in`, or appending items to the
18
18
For a similar data structure that supports memory efficient `appends`/`pops` from both sides, see [`collections.deque`][deque], which has approximately the same O(1) performance in either direction.
19
19
20
20
21
-
Because lists are mutable and can contain references to arbitrary objects, they also take up more space in memory than a fixed-size [`array.array`][array.array]type of the same apparent length.
21
+
Because lists are mutable and can contain references to arbitrary Python objects, they also take up more space in memory than an [`array.array`][array.array]or a [`tuple`][tuple] (_which is immutable_) of the same apparent length.
22
22
Despite this, lists are an extremely flexible and useful data structure and many built-in methods and operations in Python produce lists as their output.
23
23
24
24
@@ -135,7 +135,8 @@ TypeError: 'int' object is not iterable
135
135
136
136
## Accessing elements
137
137
138
-
Items inside lists (_as well as elements in other sequence types such as [`str`][string] & [`tuple`][tuple]_), can be accessed using _bracket notation_. Indexes can be from **`left`** --> **`right`** (_starting at zero_) or **`right`** --> **`left`** (_starting at -1_).
138
+
Items inside lists (_as well as elements in other sequence types such as [`str`][string] & [`tuple`][tuple]_), can be accessed using _bracket notation_.
139
+
Indexes can be from **`left`** --> **`right`** (_starting at zero_) or **`right`** --> **`left`** (_starting at -1_).
139
140
140
141
141
142
<table>
@@ -173,9 +174,11 @@ Items inside lists (_as well as elements in other sequence types such as [`str`]
173
174
'Toast'
174
175
```
175
176
176
-
A section of a list can be accessed via _slice notation_ (`<list>[start:stop]`). A _slice_ is defined as an element sequence at position `index`, such that `start <= index < stop`. [_Slicing_][slice notation] returns a copy of the "sliced" items and does not modify the original `list`.
177
+
A section of a list can be accessed via _slice notation_ (`<list>[start:stop]`).
178
+
A _slice_ is defined as an element sequence at position `index`, such that `start <= index < stop`.
179
+
[_Slicing_][slice notation] returns a copy of the "sliced" items and does not modify the original `list`.
177
180
178
-
A `step` parameter can also be used in the slice (`[start:stop:step]`) to "skip over" or filter the returned elements (_for example, a `step` of 2 will select every other element in the section_):
181
+
A `step` parameter can also be used in the slice (`<list>[<start>:<stop>:<step>]`) to "skip over" or filter the returned elements (_for example, a `step` of 2 will select every other element in the section_):
Copy file name to clipboardExpand all lines: exercises/concept/card-games/.docs/hints.md
+10-11
Original file line number
Diff line number
Diff line change
@@ -4,45 +4,44 @@
4
4
5
5
## 1. Tracking Poker Rounds
6
6
7
-
- Lists in Python may be [constructed][constructed] in several ways.
7
+
- Lists in Python may be [constructed][constructed] in multiple ways.
8
8
- This function should [return][return] a `list`.
9
9
10
10
## 2. Keeping all Rounds in the Same Place
11
11
12
-
- Sequence types such as `list`already support [common operations][common sequence operations].
12
+
- Sequence types such as `list` support [common operations][common sequence operations].
13
13
- This function should [return][return] a `list`.
14
14
15
15
## 3. Finding Prior Rounds
16
16
17
-
- Sequence types such as `list`already support a few [common operations][common sequence operations].
17
+
- Sequence types such as `list` support a few [common operations][common sequence operations].
18
18
- This function should [return][return] a `bool`.
19
19
20
20
## 4. Averaging Card Values
21
21
22
-
- To get the average, this function should count how many items are in the `list` and sum up their values. Then, return sum/count.
22
+
- To get the average, this function should count how many items are in the `list` and sum up their values. Then, return the sum divided by the count.
23
23
24
24
## 5. Alternate Averages
25
25
26
-
- Sequence types such as `list`already support a few [common operations][common sequence operations].
27
-
- To access an element use the square brackets (`<list>[]`) notation.
28
-
- Remember that the first element of the `list` is at index 0 from the left.
29
-
- In Python, negative indexing starts the count from the right-hand side. This mean that you can find the last element of a `list`at `index -1`.
26
+
- Sequence types such as `list` support a few [common operations][common sequence operations].
27
+
- To access an element, use the square brackets (`<list>[]`) notation.
28
+
- Remember that the first element of the `list` is at index 0 from the **left-hand** side.
29
+
- In Python, negative indexing starts at -1 from the **right-hand** side. This means that you can find the last element of a `list`by using `<list>[-1]`.
30
30
- Think about how you could reuse the code from the functions that you have already implemented.
31
31
32
32
## 6. More Averaging Techniques
33
33
34
34
- Sequence types such as `list` already support a few [common operations][common sequence operations].
35
35
- Think about reusing the code from the functions that you just implemented.
36
-
- The slice syntax supports a step value.
36
+
- The slice syntax supports a _step value_ (`<list>[<start>:<stop>:<step>]`).
37
37
38
38
## 7. Bonus Round Rules
39
39
40
-
- Lists are mutable. Once a `list` is created, you can modify, delete or add any type of element you wish.
40
+
- Lists are _mutable_. Once a `list` is created, you can modify, delete or add any type of element you wish.
41
41
- Python provides a wide range of [ways to modify `lists`][ways to modify `lists`].
Copy file name to clipboardExpand all lines: exercises/concept/card-games/.docs/introduction.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
A [`list`][list] is a mutable collection of items in _sequence_.
4
4
Like most collections (_see the built-ins [`tuple`][tuple], [`dict`][dict] and [`set`][set]_), lists can hold reference to any (or multiple) data type(s) - including other lists.
5
-
Like any [sequence][sequence type], items can be accessed via `0-based index` number from the left and `-1-base index` from the right.
5
+
Like any [sequence][sequence type], items can be accessed via `0-based index` number from the left and `-1-based index` from the right.
6
6
Lists can be copied in whole or in part via [slice notation][slice notation] or `<list>.copy()`.
7
7
8
8
Lists support both [common][common sequence operations] and [mutable][mutable sequence operations] sequence operations such as `min()`/`max()`, `<list>.index()`, `<list>.append()` and `<list>.reverse()`.
0 commit comments