Python Lists

Python List reverse() Method

Reverses the order of the list.

Python List sort() Method

Sorts the list in ascending order or optionally in descending order.

Python List remove() Method

Removes the first item with the specified value.

Python List pop() Method

Removes the item that is at the specified position.

Python List index() Method

Returns the index of the first item with the specified value.

Python List insert() Method

Inserts an element at the specified position.

Python Lists

Lists are used to store zero or more things in a variable. One can think of the variable as, say, a grocery bag which holds "things", which for a grocery bag would be groceries. The examples below will use this idea of a groceries. A list is a comma delimited collection of items placed inside brackets []. A list can be created with items already in it:

Python List append() Method

Adds an item to the end of the list.

Python List clear() Method

Removes all items from the list.

Python List copy() Method

Python List count() Method

Returns the number of times the given element occurs in the list.

Python List extend() Method

Adds to the end of the current list the items in another list.