0

some assistance is needed:

I've been having some trouble with the OR operand ...I understand how it works ( either or condition must be true), but i'm not sure why it is behaving in the fashion explained below.

The 'or' statement doesn't seem to be checking the second condition in my "flowContol' function.. when I enter 'y' it sees the condition as true and runs without any problems... however when i enter 'yes' it evaluates the condition as false...

-I excluded the other functions-..

def flowControl():
    answer = input("do you want run the 'displayLession' function? ( yes or 
    no)").strip()
    if answer == ('y' or 'yes'):
        displayLesson()
else:
    userTime()
    print('End program')

flowControl()

Jeff - Mci
  • 981
  • 7
  • 13

1 Answers1

0

What you are looking for is

if answer == 'y' or answer == 'yes':

Or

if answer in ['y', 'yes']:

Why? Simple, your code evaluates before what is between parentheses 'y' or 'yes' and this is 'y', because 'y' is a truthy expression in python, so no need to evaluate the latter expression.

Ursus
  • 29,643
  • 3
  • 33
  • 50