Basically, I want a simple python code to ask user to input 3 different answers to questions, and then to just write those inputs to a notepad file. The code I have been trying to use is:
user_input1 = input("What is your name: ")
user_input2 = input("What is your age: ")
user_input3 = input("What is your city: ")
with open("my_file.txt", "w") as f:
results = ({user_input1}, {user_input2}, {user_input3})
f.write,([results])
f.close()
I am a newbie (really new) to python and am learning as I go along as well as taking college courses for learning python ETC.
Any help / hints to what is going wrong would be greatly appreciated.
I have tried searching on google for every error that came up, this is the only version of my code that successfully “Finished with code 0” in the interpreter. Yet still doesn’t write to the notepad file. I do have a notepad file on the computer with this program and code etc.
I currently have both the notepad file I need it to write to and the python code file in a folder on my desktop and have been running the interpreter from in there, along with trying to run the code in there as well.
Thanks for any help!
Justin
Justin Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.