Skip to content

Update 30_lists.md #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions website/content/02_data_types/30_lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Lists are one of the most powerful data types in Python. They're used to store r
| use | Used for storing similar items, and in cases where items need to be added or removed. |
| creation | `[]` or `list()` for empty list, or `[1, 2, 3]` for a list with items. |
| search methods | `my_list.index(item)` or `item in my_list` |
| search speed | Searching for an item in a large list is slow brcause each item must be checked. |
| search speed | Searching for an item in a large list is slow because each item must be checked. |
| common methods | `len(my_list)`, `append(item)` to add, `insert(index, item)` to insert at `index`, `pop()` to remove. |
| order preserved? | Yes. Items can be accessed by index. |
| mutable? | Yes |
Expand Down Expand Up @@ -394,4 +394,4 @@ IndexError: pop index out of range
| **index** of item | `my_list.index(item)` | `int` | `ValueError` if `item` is not in `my_list` |
| **count** of item | `my_list.count(item)` | `int` | |
| **remove** an item | `my_list.remove(item)` | - | `ValueError` if `item` not in `my_list` |
| **remove** the last item, or an item at an index | `my_list.pop()` or `my_list.pop(pos)` | `item` | `IndexError` if `pos` >= `len(my_list)` |
| **remove** the last item, or an item at an index | `my_list.pop()` or `my_list.pop(pos)` | `item` | `IndexError` if `pos` >= `len(my_list)` |