0

So the problem I'm having is with this part of a simple script for a Chat Bot about Programming. But when I test this part of the script and type in 'B' as my input, it says ('Panda: I'm glad you share my enthusiasm.') which is what is mean't to happen if I input A! Can someone please point out to me what I'm doing wrong?

invalidAnswer2 = true
while invalidAnswer2 == true :
    answer2 = input (user)
    if answer2 == ('a') or ('A') :
        print ('Panda: I'm glad you share my enthusiasm.')
        invalidAnswer2 = false
    elif answer1 == ('b') or ('B') :
        print ('Panda: I wish. I am actually British, but I dream of going to America!')        
        print ('Panda: *Cough* Um anyway that was rather unproffesional of me.')
        invalidAnswer2 = false
    else :
        invalidAnswer()
        invalidAnswer2 = true

Thank You for helping me fix it. It was a simple typo after all that XD

1 Answers1

0

The problem is your that your first if statement is always True: if answer1 == "a" or "A" Will always yield true, because it's really asking:

if (answer1 == "a") or ("A")

And "A" will always return True. What you meant is probably:

if answer1 == "a" or answer1 == "A"

or the better option:

if answer1.lower() == "a"
Baryo
  • 314
  • 1
  • 9