human
Can you show me a Python function to save a variable to a text file.
assistant
Here is a Python function to save a variable to a text file

import os

def save_to_file(filename, variable):
    """ Saves a variable to a text file.
    """
    with open(filename, "w") as f:
        f.write(str(variable))

# Enter the filename
filename = "test.txt"

# Enter the variable
variable = "Hello"

# Calling the function
print((save_to_file(filename, variable)))

#Example Output
# None

#Remember to inspect code for bugs.