List = []
squares = [x**2 for x in range(5)]
squares = [x**2 for x in range(5)]
An ordered, mutable collection of elements.
Methods
append(x) → Add at the end.
insert(i, x) → Add at index i.
extend(iterable) → Concatenate another list.
pop([i]) → Remove and return element at i (default last).
remove(x) → Remove first occurrence of x.
clear() → Remove all elements.
Check Existence: x in my_list
Sort: my_list.sort() or sorted(my_list)
Reverse: my_list.reverse()
Count: my_list.count(x)
Index of Element: my_list.index(x)
Copy: my_list.copy()
len(my_list) → Length of list.
max(my_list), min(my_list) → Largest/smallest element.
sum(my_list) → Sum of elements (for numeric lists).
squares = [x**2 for x in range(5)]
List comprehension squares = [x**2 for x in range(5)]
csdf
sdfv
sdfv
sdfv
sdfv
sdfv
sdfv
sdfv
dsfv
Top comments (0)