intercept
intercept

Reputation: 65

Variable and Function help // Python

Alright so here's the code

def user_password():
input('Please Enter Password: ')

#profiles
def intercept():
    user_password()
    if user_password == "intercept":
            print("this is working so far")
    else:
            print("Incorect Password")
def Jimmy():
    user_password()
    if user_password == "Jimmy":
            print("this is working so far")
    else:
            print("Incorect Password")
def Tommy():
    user_password()
    if user_password == "Tommy":
            print("this is working so far")
    else:
            print("Incorect Password")

#login
user_functions = dict(
    intercept=intercept,
    Jimmy=Jimmy,
    Tommy=Tommy,
    # ...
)
 user_input = input("Input function name: ") 

if user_input in user_functions:
    user_functions[user_input]()
else:
    print("Error: Unknown function.")

PROBLEMS:

Upvotes: 1

Views: 261

Answers (1)

mmuzahid
mmuzahid

Reputation: 2280

I think you are trying to write something like that:

def get_user_password():
   return input('Please Enter Password: ')


def Jimmy():
    user_password = get_user_password()
    if user_password == "Jimmy":
            print("this is working so far")

Upvotes: 3

Related Questions