Skip to main content

Lists

MethodBrief descriptionSmall descriptive example
append()Adds an element to the end of the list.Adds "apple" to the list of fruits.
extend()Adds the elements of another list to the end of the current list.Joins the fruit list with the vegetable list.
insert()Inserts an element at a specific position.Inserts "pear" at position 2 of the list.
remove()Removes the first occurrence of a specific value.Removes "banana" from the fruit list.
pop()Removes and returns an element at a given position (or the last).Takes the last read book out of the list.
clear()Removes all elements from the list.Completely empties the to-do list.
index()Returns the index of the first appearance of a value.Finds the position of "grape" in the list.
count()Counts how many times a value appears in the list.Counts how many times "lemon" appears.
sort()Sorts the elements of the list (by default from lowest to highest).Sorts a list of numbers in ascending order.
reverse()Reverses the order of the elements in the list.Reverses a list of names.
copy()Returns a shallow copy of the list.Creates a copy of the shopping list.