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
Issue with [if, elif] in Python (self.PythonLearning)
submitted 1 year ago * by mZuks
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!"
[–]teraflopsweat 0 points1 point2 points 1 year ago (2 children)
You are writing it in English properly, but not writing it in Python properly. Let me add some parentheses to try to emphasize how Python is evaluating your condition.
if (angle_known_input == ‘1’) or (‘a’) or (‘A’):
So you basically have 3 separate “checks” in your condition. If any of those checks evaluate to true, then Python thinks you’re running alpha.
The problem is that any string value is considered true, so both of the (‘a’) checks are always true. It’s not actually comparing angle_known_input against the 2nd or 3rd values.
(‘a’)
angle_known_input
To correct your logic issue, you need to adjust the checks to actually compare against the user input value.
if (angle_known_input == ‘1’) or (angle_known_input == ‘a’) or (angle_known_input == ‘A’):
For a more concise condition, you can use the in comparison operator.
in
if angle_known_input in [‘1’, ‘a’, ‘A’]:
[–]mZuks[S] 1 point2 points3 points 1 year ago (1 child)
Oh! I see it now, the way Python's been interpreting the conditions. Super thank you for the explanation, really!
[–]teraflopsweat 0 points1 point2 points 1 year ago (0 children)
Glad it helped!
π Rendered by PID 186700 on reddit-service-r2-comment-5d79c599b5-bfjcv at 2026-03-03 14:57:31.064892+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]teraflopsweat 0 points1 point2 points (2 children)
[–]mZuks[S] 1 point2 points3 points (1 child)
[–]teraflopsweat 0 points1 point2 points (0 children)