Python Lists - Class 11 CBSE Notes
Definition:
A list in Python is an ordered, mutable collection of elements. Lists can store integers, strings,
floats, or even other lists. They are written with square brackets []. Key Properties: Ordered: Items
have a defined order. Mutable: You can change, add, or remove items. Heterogeneous: Can
contain different data types. Creating a List:
l = [1, 2, 3, "apple", 4.5]
Accessing Elements:
l[0] → 1
l[-1] → 4.5
Function / Method Description Example
append(x) Adds an element at the end my_list.append(10)
extend(iterable) Adds multiple elements my_list.extend([4,5])
insert(i, x) Inserts at index i my_list.insert(1, 'apple')
remove(x) Removes first occurrence my_list.remove(3)
pop([i]) Removes & returns element my_list.pop(2)
clear() Removes all elements my_list.clear()
index(x) Returns index of value my_list.index(7)
count(x) Counts occurrences my_list.count(2)
sort() Sorts list ascending my_list.sort()
reverse() Reverses list my_list.reverse()
copy() Returns a shallow copy new_list = my_list.copy()