1/19
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Which is faster for checking if an item exists: list
or set
set
Code to count word frequencies using a dict
counts = {}
for word in words:
counts[word] = counts.get(word, 0) + 1
Loop through a dict's keys and values
for key, value in my_dict.items():
print(key, value)
How to remove 'apple' from this set? fruits = {'apple', 'banana'}
fruits.remove("apple")
Create an empty set
my_set = set() NOT {}
How to get all keys from a dictionary
my_dict.keys()
Merge two sets
set1.union(set2)
Delete a key from a dict
mydict.pop("key")