- Home
- /
- Python List Methods
Python Tutorial
Introduction
Python Data Types & Oper...
Python Strings
Python Lists
Python Tuples
Python Sets
Python Dictionaries
Conditional Statements
Python Loops
Python Functions
Python Modules
Python OOPS
Advanced Topics
File Handling
- Home
- /
- Python List Methods
Python List Methods
You already know about basic list methods like append(), insert(), pop() and remove(). Now it’s time to level up with some more powerful list methods that help you sort, reverse, find, copy, and count values.
sort() – Sort List in Ascending Order
Sorts the items of the list in-place (modifies the original list). Works with both strings and numbers.
colors = ["mint", "teal", "aqua", "cyan"]
colors.sort()
print(colors)
marks = [45, 87, 23, 67, 99, 12, 45]
marks.sort()
print(marks)
Output:
['aqua', 'cyan', 'mint', 'teal']
[12, 23, 45, 45, 67, 87, 99]
sort(reverse=True) – Sort List in Descending Order
Add reverse=True if you want the items sorted in descending order.
colors = ["mint", "teal", "aqua", "cyan"]
colors.sort(reverse=True)
print(colors)
marks = [45, 87, 23, 67, 99, 12, 45]
marks.sort(reverse=True)
print(marks)
Output:
['teal', 'mint', 'cyan', 'aqua']
[99, 87, 67, 45, 45, 23, 12]
Note: reverse=True is an argument in the sort() method — it’s not the same as the reverse() method below.
reverse() – Reverse the List Order
Flips the list items without sorting.
colors = ["mint", "teal", "aqua", "cyan"]
colors.reverse()
print(colors)
marks = [45, 87, 23, 67, 99]
marks.reverse()
print(marks)
Output:
['cyan', 'aqua', 'teal', 'mint']
[99, 67, 23, 87, 45]
index() – Find Index of First Occurrence
Returns the index of the first match of a specified value.
colors = ["mint", "teal", "aqua", "mint", "cyan"]
print(colors.index("mint"))
marks = [45, 87, 23, 67, 87, 99]
print(marks.index(87))
Output:
0
1
count() – Count Occurrences
Tells you how many times a value appears in the list.
colors = ["mint", "teal", "aqua", "mint", "cyan"]
print(colors.count("mint"))
marks = [45, 87, 45, 23, 45, 99]
print(marks.count(45))
Output:
2
3
copy() – Duplicate a List
Creates an independent copy of the list. Useful if you want to preserve the original list while modifying the new one.
original = ["python", "java", "c++"]
duplicate = original.copy()
print("Original:", original)
print("Duplicate:", duplicate)
Output:
Original: ['python', 'java', 'c++']
Duplicate: ['python', 'java', 'c++']
These built-in methods help you manipulate lists cleanly and efficiently. Mastering them will make your Python code smarter and easier to manage.
Keep learning the Pythonic way — only on Learn With Arshyan.