Reputation: 93
How to do the following code, but to a text file instead of printing to console.
print("test",end="")
I tried to execute this code, but its not working.
file.write("test",end="")
Upvotes: 0
Views: 46
Reputation: 26
file.write() can't accept more than 1 argument (which is the string that should be written to the file)
with open("test.txt", "w+") as file:
for i in range(10):
file.write("test")
The result in test.txt: testtesttesttesttesttesttesttesttesttest
Upvotes: 1