How do I edit a file with a specific name according to the user
JW2005

So after I made this code, it will open a new file but the code cannot write anything into the text file I have opened. Any ways that I can do this. It is sort of like when a user inputs his or her username, the text file will open accordingly, and what the user has typed or edit, the file will append and write them in the text file. But my code doesn't work. TT

You are viewing a single comment. View All
JW2005

@VulcanWM I mean like saving their data in a file. For example in a game. When they have coins and certain items, they need to save it or else they will lose em. So, I am planning to make files for each user when they registered, and when they earn more coins, the code will edit the new coin number and automatically save it in the file. So it will be like,

coins = 1000
if player earn coins, coins += 1100
then before they exit,
a = open(username+".txt","w")
a.write(coins)
a.close

they will have their original coin value stored in that file and then when befoer they exit the new coin number will be editted through the a.write() and being saved