dimanche 29 mai 2016

How to use a function's if statement to use info from another function?

So I'm designing a sign-in AI, and I want it to work so that the admin name is Shawn. Here is my issue:

The program starts with the interface -

def interface():
username = input('Hello traveler, what is your name?  ')
lowerUsername = username.lower()
print()
print()
if lowerUsername == 'megan':
    print()
    print('So you are the one Shawn has told me so much about? You are looking beautiful today my dear ☺️đŸŒ·')
elif lowerUsername == 'shawn':
    OfficialSignInEdit()

So you can see at the end that if the user inputs that their name is 'shawn' at sign-in, it calls on the OfficialSignInEdit function, which is the admin sign in. It looks like this:

def OfficialSignInEdit():
print()
if PossInputs('perio', 'What street did you grow up on?: ') == correct:
    print()
    print('Greetings Master Shawn, it is a pleasure to see you again 🙂')
else:
    print()
    res1 = input('Incorrect password, try again? (Yes/No)')
    lowres1 = res1.lower()
    if lowres1 == 'yes':
        print()
        print()
        OfficialSignIn()
    elif lowres1 == 'no':
        print()
        print()
        interface()

So I have pinpointed the source of my issue to be right here in this particular line:

if PossInputs('perio', 'What street did you grow up on?: ') == correct:
    print()
    print('Greetings Master Shawn, it is a pleasure to see you again 🙂')

this (just for your reference) is the PossInputs function:

def PossInputs(x, y):
term = x
question = input(y)
lowQuestion = question.lower()
words = lowQuestion.split()
if term in words:
    print()
    print (correct)
else:
    print()
    print (incorrect)

So what I want to happen is, when 'shawn' is entered as a name, the program will jump to the OfficialSignInEdit Function, and ask the question 'What street did you grow up on?'. Then IF the user enters the answer 'perio', the program will print 'correct', and then print the message 'Greetings Master Shawn, it is a pleasure to see you again'. I tried to say that IF PossInputs == correct (and I did define correct = 'correct', and incorrect = 'incorrect' outside all functions) then this would happen, but instead it prints 'correct', and then 'Incorrect password, try again? (Yes/No)', so how can I make a conditional statement that says that if the user answers 'perio', then it will print the welcome message?

Just for thoroughness sake, I also tried

if PossInputs('perio', 'What street did you grow up on?: ') == True

also without success...

anyways anything you can give me is extremely appreciated, if you have any questions or you would like to to clarify something about the written code, I would be more than happy to get back with you as soon as I can.

Thanks!

Aucun commentaire:

Enregistrer un commentaire