Why is the if statement still returning my function?

38 Views Asked by At
def begin():
    response = input("Would you like to import a file? ")
    response = response.lower()
    if response is 'yes' or 'y':
        return to_import()
    else:
        print("Bummer")

My goal is that only a yes or y response will return the function and start the rest of the program. Problem is that any response at the moment will initiate to_import().

1

There are 1 best solutions below

2
On

Try separating the two conditions in the if statement:

if response is 'yes' or response is 'y':
    return to_import()
else:
    print("Bummer")