Python List Methods Cheat Sheet

Quick reference guide for Python list operations. Master appending, inserting, removing, sorting, and slicing elements.

Modifying List Elements

Methods to add, update, or remove items in a list.

MethodSyntaxDescription
append()my_list.append(item)Adds an element to the end of the list.
extend()my_list.extend(iterable)Appends all elements of an iterable to the list.
insert()my_list.insert(index, item)Inserts an element at a specified position.
remove()my_list.remove(item)Removes the first occurrence of the specified item. Raises ValueError if not found.
pop()my_list.pop([index])Removes and returns the item at the specified index (defaults to last item).

List Utility & Order

Methods for searching, sorting, and copying lists.

MethodSyntaxDescription
sort()my_list.sort(reverse=False, key=None)Sorts the list in-place.
reverse()my_list.reverse()Reverses the order of list elements in-place.
index()my_list.index(item)Returns the index of the first occurrence of the specified item.
clear()my_list.clear()Removes all elements from the list.

Frequently Asked Questions

What is the difference between append() and extend()?

append() adds its argument as a single element to the end of a list, whereas extend() iterates over its argument and adds each element separately.

How do you reverse a list without modifying it?

Use the reversed() function, or use list slicing: my_list[::-1].

Keep Learning

Recommended Python Resources

Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.