pyguides

Reference

List Methods

Methods available on Python list objects.

  1. list.append()

    Adds a single element to the end of a list, modifying it in-place

  2. list.clear()

    Removes all elements from a list, making it empty in-place

  3. list.copy()

    Creates a shallow copy of a list

  4. list.count()

    Returns the number of times a specified value appears in a list

  5. list.extend()

    Adds all elements from an iterable to the end of a list, modifying it in-place

  6. list.index()

    Returns the index of the first occurrence of a specified value in a list

  7. list.insert()

    Inserts an element at a specified position in a list, modifying it in-place

  8. list.pop()

    Removes and returns the element at the specified index in a list

  9. list.remove()

    Removes the first occurrence of a specified value from a list

  10. list.reverse()

    Reverses the elements of a list in-place, modifying the original list

  11. list.sort()

    Sorts the elements of a list in-place, modifying the original list with optional key and reverse parameters