I'm a beginner at python and im just trying to do some simple file I/O questions.
I wrote this code:
sentence=input("give a sentence:")
f=open("wordsOnLine.txt",'w')
f.write(sentence)
f.close
I just want a sentence that a user inputs to be saved in a text file. I was going to use that file for a different part of the question, but after running the code, inputting a test sentence, and checking the file, it's just empty. I didn't get any errors either.
Idk what im doing wrong. Any help would be appreciated. Thanks in advance.
f.closeis a method so you need to give it()like so:f.close()