Reinforce your Python list knowledge with structured review questions. Cover key concepts like list creation, indexing, slicing, and manipulation with clear, beginner-friendly Q&A.
A list is an ordered, mutable collection of elements enclosed in square brackets []. Lists are created by placing comma-separated values between square brackets or using the list() constructor.
["Empty list: `my_list = []` or `my_list = list()`", "Number list: `numbers = [1, 2, 3]`", "Mixed types: `mixed = [1, 'a', True, 3.14]`"]
Python lists use zero-based indexing where the first element is at index 0. Negative indices count backward from the end (-1 is last element).
["First element: `my_list[0]`", "Last element: `my_list[-1]`", "Second last: `my_list[-2]`"]
Slicing extracts a portion of a list using the syntax list[start:stop:step]. Start is inclusive, stop is exclusive, and step determines the interval.
["First 3 elements: `my_list[0:3]` or `my_list[:3]`", "Last 3 elements: `my_list[-3:]`", "Every other element: `my_list[::2]`", "Reverse: `my_list[::-1]`"]
- append(): Adds a single element to the end - extend(): Adds all elements from an iterable to the end - insert(): Adds an element at a specific position
["append: `my_list.append(4)`", "extend: `my_list.extend([4, 5])`", "insert: `my_list.insert(1, 'new')`"]
Common removal methods: - remove(): Removes first matching value - pop(): Removes item at given index (default last) - del: Deletes item(s) by index/slice - clear(): Empties entire list
["remove: `my_list.remove('a')`", "pop: `my_list.pop(1)`", "del: `del my_list[0:2]`", "clear: `my_list.clear()`"]
Tutorials, Roadmaps, Bootcamps & Visualization Projects