import os
# Define directory and file path
directory = "sod"
file_path = os.path.join(directory, "example.txt")
# Ensure the directory exists
os.makedirs(directory, exist_ok=True)
# Create and write to the file
with open(file_path, "w") as file:
file.write("This is an example text file.")
print(f"File created at: {file_path}")