Oct-31-2023, 09:47 PM
Hi,
I've in the process of learning logical operators. I have the following code which works.
Thanks in advance.
I've in the process of learning logical operators. I have the following code which works.
# high_income = input("Do you have a high income (yes/no)?: ") # good_credit = input("Do you have good credit (yes/no)?: ") # student = input("Are you a student (yes/no)?: ") # if (high_income= or good_credit) and not student: # print ("Eligable") # else: # print ("Not Eligable")I'm working to modify the code to accept user input for the same outcome but this doesn't work.
high_income = input("Do you have a high income (yes/no)?: ") good_credit = input("Do you have good credit (yes/no)?: ") student = input("Are you a student (yes/no)?: ") if high_income in (["yes"] or good_credit in ["yes"]): and not student in ["yes"]: print ("Eligable") else: print ("Not Eligable")However when I strip it down using a single variable input as a below it DOES work.
if high_income in (["yes"] or good_credit in ["yes"]): and not student in ["no"]: print ("Eligable") else: print ("Not Eligable")The outcome should be (Eligible) if high_income OR good_credit are True(yes) and NOT student. However the outcomes aren't what I would expect. I'm sure I've messed up somewhere but can't see why this won't work.
Thanks in advance.