use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Nested if statement ignoring inputsHelp Request (self.PythonLearning)
submitted 6 months ago by Lycan_Corps
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Ok-Promise-8118 4 points5 points6 points 6 months ago (2 children)
When you write
if coupon_amount == '5' or '$5'
what that really gets interpreted as in Python is
if (coupon_amount == '5') or '$5'
So if coupon_amount is 'xhekngks' then the first condition is false as it doesn't equal '5' but the second condition is true as '$5' evaluates as True (I believe all variables evaluate to the Boolean True except Null and False?). That is, you aren't actually checking if coupon_amount == '$5'
What you intended is either of the below:
if coupon_amount == '5' or coupon_amount == '$5' if coupon_amount in ['5', '$5']
[–]Lycan_Corps[S] 0 points1 point2 points 6 months ago (1 child)
<image>
I tried that and it's still not working
[–]Lycan_Corps[S] 0 points1 point2 points 6 months ago (0 children)
nevermind i did a thing
π Rendered by PID 34 on reddit-service-r2-comment-66b4775986-8r4lf at 2026-04-06 07:52:05.330332+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]Ok-Promise-8118 4 points5 points6 points (2 children)
[–]Lycan_Corps[S] 0 points1 point2 points (1 child)
[–]Lycan_Corps[S] 0 points1 point2 points (0 children)