Complete the code to remove the key 'b' from the dictionary.
my_dict = {'a': 1, 'b': 2, 'c': 3}
my_dict.[1]('b')
print(my_dict)The pop method removes a key from a dictionary and returns its value.
Complete the code to remove the key 'x' safely without error if it does not exist.
data = {'x': 10, 'y': 20}
removed = data.[1]('x', None)
print(data, removed)The pop method can take a default value to avoid errors if the key is missing.
Fix the error in the code to remove the key 'k' from the dictionary.
d = {'k': 5, 'm': 7}
d.[1]('k')
print(d)pop is the correct method to remove a key from a dictionary.
Fill both blanks to remove all keys with values less than 5 from the dictionary.
d = {'a': 3, 'b': 7, 'c': 2}
for key in list(d.[1]()):
if d[key] [2] 5:
d.pop(key)
print(d)Use keys() to iterate over keys and remove those with values less than 5 using <.
Fill all three blanks to create a new dictionary excluding entries with value 0.
original = {'x': 0, 'y': 5, 'z': 0}
filtered = { [1]: [2] for [3] in original.items() if [2] != 0 }
print(filtered)Use k, v to unpack items, then build a dictionary with keys k and values v excluding zeros.
