Chapter 7 Part 2 Flashcards
Slice
A span of items that are taken from a sequence
Describe list[ : ]
list is what you want to slice followed the the start:end:step.
What is the in operator?
You use the in operator to determine whether an item is in a list.
list.append(item)
Used to add items to a list (added at the end of the list).
list.index(item)
Finds the item’s location in a list.
list.insert(index,item)
Used to insert something in a specific index location.
list.sort()
Sorts the elements of the list in ascending order.
list.remove(item)
Removes the first occurrence of an item.
list.reverse()
Reverses the order of the elements in a list.
del Statement
Removes an element from a specific index in a list.
del list[i]
min(list) and max(list) Functions
Built-in functions that returns the highest or lowest value in a sequence.
What are the two ways to copy a list?
- concatenate with a new list
2. create a loop that puts the elements of the list into a new list