Nov-28-2017, 01:17 PM
(This post was last modified: Nov-28-2017, 02:14 PM by sparkz_alot.)
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
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