I'm making my first Python program using Python 3 but for some reason it gives me an error -
i wanted test program in middle of writing it, won't start reason
code:
def main(): menu() def menu(): print("1.login\n2.register\n\n1.help") input = int(input("enter corresponding number action executed: ")) if input==3: help() if input==2: register() if input==1: login() def help(): print("\nif enter number 1 (1) prompted login system\nif enter number 2 (2) prompted register, can login") def register(): usernamer = input("enter username: ") open("usernamesr.txt","wt") output: output.write(usernamer) print("your username is: "+usernamer) passwordr = str(input("\nenter password: ")) open("passwordsr.txt","wt") output: output.write(passwordr) print("your password is: "+passwordr) def login(): print("") if __name__=="__main__": main()
this error got:
1.login
traceback (most recent call last):
2.register
file "c:/users/joseph/pycharmprojects/learningpython/login_system.py", line 30, in main()
1.help
file "c:/users/joseph/pycharmprojects/learningpython/login_system.py", line 2, in main
menu()
file "c:/users/joseph/pycharmprojects/learningpython/login_system.py", line 5, in menu input = int(input("enter corresponding number action executed: "))
unboundlocalerror: local variable 'input' referenced before assignment
input()
ins in build function,
in code give variable name input
, give different variable name.
def menu(): print("1.login\n2.register\n\n1.help") input = int(input("enter corresponding number action executed: ")) # ^^^^
Comments
Post a Comment