Here is my code:
f = open("text.txt", "w+")
var2 = input()
f.write(var2'\n')
How can I make this work?
Here is my code:
f = open("text.txt", "w+")
var2 = input()
f.write(var2'\n')
How can I make this work?
This should work
f = open("text.txt", "w+")
var2 = input()
f.write(var2 + '\n')
f.close()
But, this is a better way to do it
with open("text.txt", "w+") as f:
f.write(var2 + '\n')
if var
is a string, you can just do f.write(var + '\n')
. If var
is not a string, you will need to do f.write(str(var) + '\n')