human
Can you show me a Python function to delete from a dictionary if there exists.
assistant
Here is a Python function to delete from a dictionary if there is one

import json

def delete_if_exists(dictionary, key):
    """ Delete from a dictionary if exists

    Args:
        dictionary (dict): Dictionary
        key (str): Key

    Return:
        None
    """
    if key in dictionary:
        del dictionary[key]

# Enter the dictionary
dictionary = {"key1": "value1", "key2": "value2"}

# Calling the function
print((delete_if_exists(dictionary, "key1")))

#Example Output
# None

#Remember to inspect code for bugs.