title: Why wont variable line1 and line2 write to the file 'USERDATA.py'?
body: <p>Im sorry if this is the wrong area to post this. It has been a while since I have touched python (code in general) so the code i have presented is most likely horrendous but it wont write variable line1 and line2 to the USERDATA.py file and i cant figure out why, any help would be appreciated. Cheers</p>
  
  <pre><code>    #import
  import os
  
  #
  runstartText = 'Start success'
  print(runstartText)
  
  #setting values
  file1 = './data'
  file2 = './data/userpass'
  file3 = './data/userpass/access.py'
  newUserTEXT1 = 'Please input a valid email, username and password'
  
  #checking/creating directorys
  if not os.path.exists(file1):
      os.makedirs(file1)
      print('Created', file1)
  
  if not os.path.exists(file2):
      os.makedirs(file2)
      print('Created', file2)
  
  
  #def
  def newUser():
      print(newUserTEXT1)
      username = input('Enter New System Username: ')
      password = input('Enter New System Password: ')
      passwordConfirm = input('Re-Enter New System Password: ')
      if password == passwordConfirm:
          print('Username and Password Stored')
          line1 = 'username = ', username
          line2 = 'username = ', password
          apples = 1
          if apples == 1:
              userdatafile = open('USERDATA.py', 'w+')
              userdatafile.writelines([line1, line2,])
              userdatafile.close()
  
  
          #-&gt; store data
          #-&gt; to login
      if password != passwordConfirm:
          print('ERROR: Passwords do not match, please retry')
          #-&gt; restart newUser string
  
  def login():
      from USERDATA import username, password
      print('Please Enter Username and Password:')
      usernameTEMP = input('Username: ')
      if usernameTEMP == username:
          passwordTEMP = input('Password: ')
          if passwordTEMP == password:
              print('Successful Login!')
              # -&gt; to login
  </code></pre>