from datetime import date calculations = [ '$1.00 NZD is ¥85.00 JPY', '$2.00 NZD is ¥170.00 JPY', '$5.00 NZD is ¥425.00 JPY', '¥850.00 JPY is $10.00 NZD', '¥1700.00 JPY is $20.00 NZD', '¥4250.00 JPY is $50.00 NZD' ] # **** Get current date for heading and filename **** today = date.today() # Get day, month and year as individual strings day = today.strftime("%d") month = today.strftime("%m") year = today.strftime("%Y") file_name = f"currency_{year}_{month}_{day}" write_to = f"{file_name}.txt" with open(write_to, "w") as text_file: text_file.write("***** Currency Conversion Calculations ******\n") text_file.write(f"Generated: {day}/{month}/{year}\n\n") text_file.write("Here is your calculation history (oldest to newest)... \n") # write the items to file for item in calculations: text_file.write(item) text_file.write("\n")