-1

Hello I made a login system which stores usernames and password but it currently only holds one and every time I add a new one it deletes the old one how could I make so it continuously adds more to the list here is my code

def register_user():
   username_info = username.get()
   password_info = password.get()
 
   file = open("info.txt","w")
   file.write('username= '+username_info + "\n")
   file.write('password= '+password_info)
   file.close()
Daweed
  • 1,419
  • 1
  • 9
  • 24
  • The "mode" argument should be "a" instead of "w". Other modes can be found in the Python documentation. – Michael Butscher Apr 02 '21 at 18:10
  • Change the ```"w"``` argument to ```"a"```. – Daweed Apr 02 '21 at 18:10
  • Please repeat [on topic](https://stackoverflow.com/help/on-topic) and [how to ask](https://stackoverflow.com/help/how-to-ask) from the [intro tour](https://stackoverflow.com/tour). Stack Overflow is not intended to replace existing documentation and tutorials. – Prune Apr 02 '21 at 18:15

1 Answers1

0

Open it in append mode with "a":

file = open("info.txt","a")

Other modes can be found in the Python docs.

SuperStormer
  • 4,997
  • 5
  • 25
  • 35