title: return variables from functions python
body: <p>I have come across a problem with returning two variables from a function, although I have set the variables to be global. The program I am making is designed to imitate the process of adding a user and login in to that user or changing said user's password.</p>
  
  <pre><code>check = False
  
  global uname
  global pword
  
  uname = 0
  pword = 0
  
  while check == False:
  
  
  def user(uname, pword):
      set_uname = input("Enter username: ")
      set_pword = input("Enter password: ")
      print("Username and Password set")
  
      return(set_uname, set_pword)
  
  def login(uname, pword):
      correct = False
      while correct == False:
          enter_uname = input("Enter username: ")
          enter_pword = input("Enter password: ")
          if enter_uname == uname and enter_pword == pword:
              print("Login successful")
          elif enter_uname != uname or enter_pword != pword:
              print("Incorrect username or password")
              correct = False
  
  def cpword(pword):
      done = False
      while done == False:
          check_pword = input("Enter current password: ")
          if check_pword == pword:
              new_pword = input("Enter new password: ")
              if new_pword == pword:
                  print("New password cannot be old password")
                  done = False
              elif new_pword != pword:
                  print("Password successfully changed")
                  pword = new_pword
                  done = True
                  return(pword)
          elif check_pword != pword:
              print("Incorrect password")
              done = False
  
  print("Enter User")
  user(uname, pword)
  
  uname = set_uname
  pword = set_pword
  
  print("Login = 1")
  print("Change Password = 2")
  
  choice = int(input("Enter function: "))
  
  if choice  == 1:
      login(uname, pword)
  elif choice == 2:
      cpword(pword)
      pword = pword
  </code></pre>
  
  <p>I keep receiving the error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):
      File "C:\Users\tay.swain\Documents\Login.py", line 54, in 
        uname = set_uname
      NameError: name 'set_uname' is not defined</p>
  </blockquote>
  
  <p>Once i set the user, when I run the login function this error appears. I am trying to return</p>
  
  <blockquote>
    <p>return(set_uname, set_pword)</p>
  </blockquote>
  
  <p>from the user function. I understand how to return variable from a function as I have done it before, however I cannot get it to work in this code.</p>