Python Forum
Saving the results from an input in a txt. file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving the results from an input in a txt. file
#1
Im currently working on a school project where I have to make a multiplication table where you put in a value for the size you want the table to be. I want my program to save the results to "gangetabell.txt", but I cant seem to figure out how to save the results to the file. My problem is how to put the code as an argument inside the write() function.

Here is the code:

print("\t\tGangetabell\n")

n =int(input('Vennligst skriv inn et tall: '))
for row in range(1,n+1):
for col in range(1,n+1):
print(row*col, end="\t")
print('\n')
saveFile = open('gangetabell.txt', 'w')
saveFile.write()
saveFile.close()



And this is the error I get:

Traceback (most recent call last):
File "C:/Users/Erlend/PycharmProjects/python_2/oppg_2.py", line 9, in <module>
saveFile.write()
TypeError: write() takes exactly one argument (0 given)

Process finished with exit code 1
Reply


Messages In This Thread
Saving the results from an input in a txt. file - by pythonenthusiast - Nov-28-2017, 01:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help implementing an input with file operations Gaijin 3 2,139 Jun-08-2022, 05:50 PM
Last Post: Gaijin
  Changing the content of the table and saving the new data into another file femke_pythonquestion123 1 1,617 Sep-18-2020, 12:06 PM
Last Post: femke_pythonquestion123
  how to add the user input from file into list wilson20 8 4,409 May-03-2020, 10:52 PM
Last Post: Larz60+
  Saving to Json file Shambob1874 1 2,506 May-30-2018, 10:00 PM
Last Post: micseydel
  Saving an numpy.ndarray as .ply file in python Tina 4 17,190 Oct-11-2017, 06:08 PM
Last Post: Tina

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020