how to save text into variable in python code example Example: output variable to text file python file.write("a_dictionary = " + str_dictionary + "\n")