# This program demonstrates how numbers # must be converted to strings before they # are written to a text file. def main(): # Open a file for writing. outfile = open('numbers1.txt', 'w') # Get three numbers from the user. num1 = int(input('Enter a number: ')) num2 = int(input('Enter another number: ')) num3 = int(input('Enter another number: ')) # Write the numbers to the file. # You can use the print function, specifying the # file as an argument. # Print will do conversion to strings for you. print(num1,file=outfile) print(num2,file=outfile) print(num3,file=outfile) # Close the file. outfile.close() print('Data written to numbers1.txt') # Call the main function. main()