BestPromptFinderBelow is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Generate a Python program to delete a given key from a dictionary. ### Input: dictionary = {'foo': 1, 'bar': 2, 'baz': 3} key = 'baz' ### Output: dictionary = {'foo': 1, 'bar': 2, 'baz': 3} key = 'baz' def delete_key(dic, k): if k in dic: del dic[k] delete_key(dictionary, key) print(dictionary)
Find similar in the app →