title: How to create a python dictionary that will store the username and password for multiple accounts
body: <p>The problem I have right now is that for my dictionary that uses a key:value to store username:password is that every time I rerun the program, the current key:value is reset and the dictionary is set to empty again. The goal of my program is to have a person log in with a username and password and be able to store notes and passwords (I did this with python .txt files). Then the next person can come along, create an account and do the same. Here is my code (I have commented every line of code pertaining to my problem):</p>
  
  <pre><code>def userPass():
  checkAccount = input("Do you have an account (Y or N)?")
  if (checkAccount == 'N' or checkAccount == 'n'):
      userName = input("Please Set Your New Username: ")
      password = input("Please Set Your New Password: ")
  //  if (userName in dictAcc):
          print("Username is taken")
          userPass()
      else:
  //      dictAcc[userName] = password 
          print("Congratulations! You have succesfully created an account!")
          time.sleep(1.5)
          dataInput()
  elif(checkAccount == 'Y' or checkAccount == 'y'):
      login()
  else:
      print("Invalid answer, try again")
      userPass()
  
  
  def login():
  global userName
  global password
  global tries
  loginUserName = input("Type in your Username: ")
  loginPass = input("Type in your Password: ")
  if (tries &lt; 3):
  //  for key in dictAcc:
  //      if (loginUserName == key and loginPass == dictAcc[key]):
  //          print("You have successfully logged in!")
              dataInput()
          else:
              print("Please try again")
              tries += 1
              login()
          if (tries &gt;= 3):
              print("You have attempted to login too many times. Try again later.")
              time.sleep(300)
              login()
  
  userPass()
  </code></pre>