Master Python lists with this curated collection of 17 structured practice challenges spanning all essential sequence operations, method behaviors, and algorithmic patterns.
Interactive Practice Problem Set: Each challenge features an interactive solution toggle, syntax-highlighted code, dedicated terminal output, and technical notes. Practice operations across append(), extend(), insert(), remove(), pop(), copy(), sort(), and clear().
my_list = []
my_list.append('Alex')
my_list.append('Ronn')
my_list.append('Geek')
print("Populated list:", my_list)Terminal Output:
Populated list: ['Alex', 'Ronn', 'Geek']
mixed = ['Alex', 4, 'Ronn', 6.54]
print("List type: ", type(mixed))
print("Item at index 2:", mixed[2])Terminal Output:
List type: <class 'list'>
Item at index 2: Ronn
stepped_list = list(range(5, 50, 10))
print("Stepped list:", stepped_list)Terminal Output:
Stepped list: [5, 15, 25, 35, 45]
nums = [10, 20, 30, 40, 50]
print("Last item (-1): ", nums[-1])
print("Second-to-last (-2): ", nums[-2])Terminal Output:
Last item (-1): 50
Second-to-last (-2): 40
data = [2, 4, 1, 5, 3, 7]
print("Slice [1:]: ", data[1:])
print("Slice [2:4]: ", data[2:4])Terminal Output:
Slice [1:]: [4, 1, 5, 3, 7]
Slice [2:4]: [1, 5]
names = ["Alex", "Ronald", "John", "Sarah"]
target = "John"
if target in names:
print(f"'{target}' located at index:", names.index(target))Terminal Output:
'John' located at index: 2
queue = ["User1", "User2"]
queue.append("User3") # Added to end
queue.insert(1, "VIP_User") # Inserted at index 1
print("Updated queue:", queue)Terminal Output:
Updated queue: ['User1', 'VIP_User', 'User2', 'User3']
base = [1, 2]
base.extend([3, 4])
print("After extend():", base)
nested = [1, 2]
nested.append([3, 4])
print("After append():", nested)Terminal Output:
After extend(): [1, 2, 3, 4]
After append(): [1, 2, [3, 4]]
items = ["apple", "banana", "cherry", "date"]
items.remove("banana") # Deletes by matching value
popped = items.pop(1) # Removes and returns item at index 1
print("Popped item: ", popped)
print("Remaining list:", items)Terminal Output:
Popped item: cherry
Remaining list: ['apple', 'date']
original = ["a", "b", "c"]
snapshot = original.copy()
original.clear()
print("Original after clear():", original)
print("Preserved snapshot: ", snapshot)Terminal Output:
Original after clear(): []
Preserved snapshot: ['a', 'b', 'c']
nums = [10, 20, 10, 30, 10, 40]
print("Total length:", len(nums))
print("Count of 10: ", nums.count(10))Terminal Output:
Total length: 6
Count of 10: 3
letters = ['a', 'b', 'c', 'd']
letters.reverse()
print("Inverted list:", letters)Terminal Output:
Inverted list: ['d', 'c', 'b', 'a']
words = ["Alexander", "Sam", "Christopher", "Jo"]
words.sort(key=len)
print("Ascending by length: ", words)
words.sort(key=len, reverse=True)
print("Descending by length:", words)Terminal Output:
Ascending by length: ['Jo', 'Sam', 'Alexander', 'Christopher']
Descending by length: ['Christopher', 'Alexander', 'Sam', 'Jo']
raw_tags = ["python", "spam", "tutorial", "spam", "coding"]
# dict.fromkeys preserves order in O(N) linear time
unique_tags = list(dict.fromkeys(raw_tags))
print("Deduplicated tags:", unique_tags)Terminal Output:
Deduplicated tags: ['python', 'spam', 'tutorial', 'coding']
scores = [45, 12, 89, 3, 67]
print("Sum: ", sum(scores))
print("Minimum:", min(scores))
print("Maximum:", max(scores))Terminal Output:
Sum: 216
Minimum: 3
Maximum: 89
text = "programming"
char_list = list(text)
unique_chars = list(dict.fromkeys(char_list))
print("Character list: ", char_list)
print("Deduplicated chars:", unique_chars)Terminal Output:
Character list: ['p', 'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g']
Deduplicated chars: ['p', 'r', 'o', 'g', 'a', 'm', 'i', 'n']
list_a = [1, 2, 3, 4, 5]
list_b = [3, 4, 5, 6, 7]
common_items = sorted(list(set(list_a) & set(list_b)))
print("Common elements:", common_items)Terminal Output:
Common elements: [3, 4, 5]
Work through all 17 challenges and self-validating assertions in our companion Jupyter Notebook:
Explore interactive code cells for all challenges, test list slicing, benchmark methods, and run self-validating unit assertions.
View on GitHub Run in Google ColabUse if item in my_list: my_list.remove(item) or a try-except ValueError block.
list(dict.fromkeys(my_list)) runs in O(N) time and maintains original insertion order.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.