Chapter 7 Flashcards
Sequence
An object that contains multiple items of data. The items are stored in sequence, one item after the other.
List
An object that contains multiple data items
Element
An item in a list.
Repetition operator
Makes multiple copies of a list and joins them together. The * operator is a repetition operator when applied to a sequence and an integer. General format:
list * n
Index
A number specifying the position of an element in a list.
len() function
Returns the length of a sequence such as a list.
Concatenate
Join two things together.
Slice
A span of items that are taken from a sequence.
append(item)
Used to add items to a list. Item is appended to the end of the existing list.
index(item)
Used to determine where an item is located in a list. Returns the index of the first element in the list containing item.
insert(index, item)
Used to insert item at position index in the list.
sort():
Used to sort the elements of the list in ascending order.
remove(item)
Removes the first occurrence of item in the list.
reverse()
Reverses the order of the elements in the list.
del statement
Removes an element from a specific index in a list. General format:
del list[i]