Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help me!!!!
#1
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
Reply
#2
Can you try posting again, with the indentation as you have it?
Reply
#3
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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020