Python Forum

Full Version: help me!!!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Someone please help with my code 

users = {}
create = ""

def displayMenu():
create = input("If you want to create a new account press C(then press enter :) ) \nIf you already have an account press N(then press enter :) )")
if create == "c":
newUser()
elif create == "n":
oldUser()

def newUser():
userN_new = input("Input your desired username")
import getpass
userP_new = getpass.getpass("Input your desired password")
print("Welcome " + userN_new)

def oldUser():
userN_old = input("Input your username")
import getpass
userP_old = getpass.getpass("Input your password")

if userN_old in users: 
        print("\nLogin successful!\n")
else:
        print("\nUser doesn't exist or wrong password!\n")
        

while create != "q":            
    displayMenu()
I keep getting this error:
 Traceback (most recent call last):

  File "C:\Users\Joel Harawa\Documents\leeman\leeman.py", line 22, in <module>
    if userN_old in users:
NameError: name 'userN_old' is not defined
Can you try posting again, with the indentation as you have it?
You have no any indentation. It's not clear where any of the functions end. If userN_old is defined inside a function, only that function can see it. You have to return it. Please, preserve a proper indented code to see what is going on! Thanks  Smile