title: How to make sign up and login program in Python?
body: <p>I'm trying to make a program that people can assign a username and password and then sign in. I was thinking about making two functions, one for sign up and one for login. However, it seems that it can't work because I assign a username in register part but when the sign in function runs it says that username is not defined. Do you have any idea what should I do?</p>
  <pre><code>def register():
      names=[]
      usernames=[]
      passwords=[]
      names.append(input(&quot;Enter your name:&quot;))
      usernames.append(input(&quot;choose your username:&quot;))
      passwords.append(input(&quot;choose your password:&quot;))
      return usernames
  def login(usernames,passwords):
      usernames=[]
      passwords=[]
      password=&quot;&quot;
      username=&quot;&quot;
      username=input(&quot;Enter your username:&quot;)
      password=input(&quot;Enter your Password:&quot;)
      if password==passwords[usernames.index(username)]:
         print(&quot;welcome&quot;)
      else:
         print(&quot;incorrect!&quot;)
  
  account_ans=&quot;&quot;
  while True:
      account_ans=input(&quot;choose:  a)Sign Up     b)login and shop     c)quit&quot;)
      if account_ans==&quot;a&quot;:
         register()
      if account_ans==&quot;b&quot;:
         password=&quot;&quot;
         username=&quot;&quot;
         usernames=[]
         passwords=[]
         login(usernames,passwords)
      if account_ans==&quot;c&quot;:break
  </code></pre>