human
Write me a Python function to write a string to a file in 2 seconds.
assistant
Here is a Python function to write a string to a file in 2 seconds

import os

def write_to_file(file_name, string):
    """Write a string to a file."""
    with open(file_name, 'w') as f:
        f.write(string)

# Enter the file name
file_name = "test.txt"

# Calling the function
print((write_to_file(file_name, "This is a test")))

# Printing the result
print((os.path.isfile(file_name)))

#Example Output
# None
# True

#Remember to inspect code for bugs.