1/52
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
append(x)
Add item to end of list
pop([i])
Remove and return item (default is last)
insert(i, x)
Insert item at index
remove(x)
Remove first occurrence of value
reverse()
Reverse list in place
sort()
Sort list in place
extend(iterable)
Add items from another iterable
count(x)
Count number of times value appears
index(x)
Return first index of value
len(lst)
Get number of elements
list[start:end:step]
Slice list
add(x)
Add element
discard(x)
Remove if exists
union(set2)
Combine sets
intersection(set2)
Common elements
difference(set2)
Elements in one but not the other
in
Check membership
len(set)
Get size
get(key, default)
Get value or default
keys()
All keys
values()
All values
items()
All key-value pairs
pop(key)
Remove key and return value
update(other_dict)
Add/replace items from another dict
len(dict)
Number of key-value pairs
split(sep)
Split into list
join(list)
Join list into string
strip()
Remove surrounding whitespace
startswith(s)
Check start
endswith(s)
Check end
replace(old, new)
Replace substring
find(s)
Find index of substring
lower()
To lowercase
upper()
To uppercase
len(s)
Length of string
s[start:end]
Slice string
range(n)
Sequence from 0 to n-1
enumerate(iterable)
Index + value
zip(a, b)
Pair elements
map(func, iterable)
Apply function
filter(func, iterable)
Filter by function
any(iterable)
True if any True
all(iterable)
True if all True
sum(iterable)
Total of items
max(iterable)
Largest value
min(iterable)
Smallest value
sorted(iterable)
Return sorted version
heapq.heappush(heap, x)
Add to min-heap
heapq.heappop(heap)
Remove min from heap
deque.append(x)
Add to right side
deque.popleft()
Remove from left side
collections.Counter()
Count frequencies
collections.defaultdict(type)
Auto-creating dict