#πŸ”’ My if and else statement is outputting wrong results

10 messages Β· Page 1 of 1 (latest)

reef wharf
#

I need it to output (You do not qualify for the 100% discount. Please return when you have a become a fan of the greatest movie franchise of all time >:(! ") when i input my age 19 and when i type false.

no_membership = False
is_membership = True
age = int(input(" What is your age? "))
membership_status = bool(input(" Are you a member of the Planet of The Apes Fanclub? Enter True for yes or False for No. "))

if is_membership == True and age >= 18:
print(" Thank you for being a member of the fanclub, your discount is 100%! ")
elif age < 18:
print(" Sorry you do not qualify for the 100% discount. Please come back when you are 18 years of age or older! ")
elif no_membership == False and age >= 18:
print(" You do not qualify for the 100% discount. Please return when you have a become a fan of the greatest movie franchise of all time >:(! ")

fossil drumBOT
#

@reef wharf

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

small yacht
#

!e print(bool("false"))

fossil drumBOT
#

@small yacht :white_check_mark: Your 3.12 eval job has completed with return code 0.

True
small yacht
#

The string "false" is not converted to the boolean False. Rather, a non-empty string (everything except "") is "truthy", and evaluates to True.

#

You would need to actually check the value of that string in order to get False correctly.

#

Although you also have three different variables, no_membership, is_membership, and membership_status. Only the last one is being changed by the input; no_membership will always be False in the above example, and is_membership will always be True.

You may need to choose exactly what you want to do with that input and whether the other values are needed.

reef wharf
#

Thank you for the help 🫑

fossil drumBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.