Boolean Iterations and Lists
Notes on 3.8 and 3.10
List and Iterations Notes
Lists
- Already took notes on this
- List is one of the four collection data types in Python, other 3 are called:
- Tuple
- Set
- Dictionary
- List commands:
Method | Definition | Examples |
append() | adds element to the end of the list | fruits.append("watermelon") |
index() | returns the index of the first element with the specified value | fruits.index("apple") |
insert() | adds element at given position | fruits.insert(1, "watermelon") |
remove() | removes the first item with the specified value | fruits.remove("strawberry") |
reverse() | reverses the list order | fruits.reverse() |
sort() | sorts the list | fruits.sort() |
count() | returns the amount of elements with the specified value | fruits.count("apple) |
copy() | returns a copy of the list | fruits.copy() |
clear() | removes the elements from the list | fruits.clear() |