human
remove key from dictionary if exist.
assistant
Here is a Python function to remove key from dictionary if there is one

import re

def remove_key_from_dict(dictionary, key):
    """Removes key from dictionary if exist.

    If key is not in dictionary, returns dictionary.
    """
    if key in dictionary:
        del dictionary[key]
    return dictionary

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

# Enter the key
key = "key1"

# Calling the function
print((remove_key_from_dict(dictionary, key)))

#Example Output
# {'key2': 'value2'}

#Remember to inspect code for bugs.