Advertisement
John5617

Add user input to list and then save to file

Jul 26th, 2019 (edited)
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. #First run this program to set up the files
  2.  
  3. import pickle
  4.  
  5. pickle.dump([],open("usernames.dat","wb"))
  6. pickle.dump([],open("emails.dat","wb"))
  7. pickle.dump([],open("passwords.dat","wb"))
  8.  
  9.  
  10. #Then replace your program with this
  11.  
  12.  
  13. import pickle
  14.  
  15. Usernames=pickle.load(open('usernames.dat','rb'))
  16. Emails=pickle.load(open('emails.dat','rb'))
  17. Passwords=pickle.load(open('passwords.dat','rb'))
  18.  
  19.  
  20. print('Type SU to Sign Up or type LI to Log In!')
  21. UOption = input('Option>> ')
  22.  
  23. if UOption == 'SU':
  24.     SI = True
  25.     LI = False
  26.     if SI == True:
  27.         print('Signing Up!')
  28.         SUUsername = input('Username>> ')
  29.         SUEmail = input('Email>> ')
  30.         SUPassword = input('Password>> ')
  31.  
  32.     Usernames.append(SUUsername)
  33.     Emails.append(SUEmail)
  34.     Passwords.append(SUPassword)
  35.     LI = True
  36.     SI = False
  37.  
  38.  
  39. pickle.dump(Usernames,open("usernames.dat","wb"))
  40. pickle.dump(Emails,open("emails.dat","wb"))
  41. pickle.dump(Passwords,open("passwords.dat","wb"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement