Im working on a saving system for user names right now. The current variable looks like this: name = input("What is your name"). I have it writing out to a text file.
I tried setting name as a variable without the input, and tried making the input the write function (idk why). No luck with either of those.
def welcome():
os.system('cls' if os.name == "nt" else 'clear')
print(color.color.DarkGray + "Welcome...")
sleep(5)
name = input("Enter Name Here: ")
name1 = name
saveUserInp = open("userNames.txt", 'w')
with open ("userNames.txt") as f:
f.write(name)
sleep(5)
print("Welcome",name1)
sleep(5)
menu()
Provided above is the code for the welcome function.
Traceback (most recent call last):
File "main.py", line 54, in <module>
welcome()
File "main.py", line 21, in welcome
f.write(name)
io.UnsupportedOperation: not writable
Provided is the actual error given. Line 54 is calling the welcome function, which breaks after I type in my name. Like 21 is the f.write function. I am not sure why it doesn't want to write it into the file.