title: How do I write a username and password to a record in a csv (txt) file through an account creation function that uses confirmation?
body: <p>I was wondering how I can write the users' input for 'account' and 'password_3' to a csv (txt) file as part of an account creation function. I am also trying to loop the function if 'password_4' does not have an input identical to 'password_3' or if any input has a length of 0. I would like both 'account' and 'password_3' to be written in the csv (txt) file as one new record. E.g:</p>
  
  <pre><code>account_1,password_1
  account_2,password_2
  etc......,etc.......
  </code></pre>
  
  <p>This is what I have come up with so far:</p>
  
  <pre><code>def create_account():
      account = ""
      print "Create Account"
  # Prompts user for input of account, password and password confirmation.
      account = raw_input("Enter login: ")
      password_3 = raw_input("Enter passsword: ")
      password_4 = raw_input("Confirm password: ")
  # Sets the condition that if one input has a length of 0, the create_account function will loop.
      while len(account) == 0 or len(password_3) == 0 or len(password_4) == 0:
          create_account()
  # Sets the condition that if the password input and password confirmation input do not match, the create_account function will loop.
      while password_3 != password_4:
          create_account()
  # Sets the condition that if both of the coniditions set above are false, input will be stored and the loop will be broken.
      else:
          with open('User.csv','w',newline='') as fp:
              a = csv.writer(fp,delimeter=',')
              data = [account,password_3]
              a.writerows(data)
  ## Writes input to the csv file for later use. Input is stored as one new record.
  </code></pre>
  
  <p>Sorry if this seems confusing or complicated. Please take into consideration that I am completely new to coding and Python. Thank you.</p>