0

This is my code:

def main():

name = input("What's your name?")
req1 = input("Do you have a GPA 3.0 or higher?")
req2 = input("Are you currently attending math courses?")
req3 = input("Do you enjoy math?")
if(req1 == "y", "Yes", "yes" or req2 == "y", "Yes", "yes"):
    req1or2 = 1
else:
    req1or2 = 0
if(req3 == "y", "Yes", "yes"):
    req3 = 1
else:
    req3 = 0
if(req1or2 == 1 and req3 == 1):
    print("Congratulations " + str(name) + "!")
    print("You're in the math club now!")
else:
    print("Try again next semester")

main()

and its always printing the first if strings even when the condition is false

oxil764
  • 1
  • 1
  • Just because you _think_ the condition is false doesn't mean it _is_ false. `print(bool((req1 == "y", "Yes", "yes" or req2 == "y", "Yes", "yes"))` and compare the result you _get_ to the result you _expected_, before assuming that it's the behavior of `if` itself at fault. :) – Charles Duffy May 27 '22 at 16:10
  • instead of testing `Yes`, `yes` separately you can `req1 = input("Do you have a GPA 3.0 or higher?").lower()` which convert the input to lowercase which you can use in `if/else` – Kunal Tanwar May 27 '22 at 16:10
  • Also what is `req1or2` ?? whats the point for this variable?? – Kunal Tanwar May 27 '22 at 16:11
  • ...similarly, `print(repr(req1 == "y", "Yes", "yes" or req2 == "y", "Yes", "yes"))` can be a useful bit of assumption-checking, to compare what that expression actually evaluates to to what you _think_ it'll evaluate to. – Charles Duffy May 27 '22 at 16:13

0 Answers0