f = open("Ttesting.txt","w") #opens file with name of "Ttesting.txt"
f.write("I am a test file.")
f.write("Maybe someday, he will promote me to a real file.")
f.write("Man, I long to be a real file")
f.write("and hang out with all my new real file friends.") f.close()
Thats how you open, write and close a file.
Hope it helps.
http://adollarfix.co.nr/
I am writing a code using Python. And I want the user to enter something and this should be saved as a text file.
However, if the user enters "Ttesting", I can't create a text file without it having .txt.
How can I add .txt to whatever the user enters.
Please help me I am new to Python...