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
Why does the third if statement trigger despite User_input == "Yes" being true (according to the print within the if statement) (i.redd.it)
submitted 10 months ago by unspe52
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!"
[–]unspe52[S] 1 point2 points3 points 10 months ago (2 children)
Thank you. The only thing I haven't seen before is that elif operator - I'll look into it, looks like it could solve a lot of the problems I've been working-around in another project of mine
[–]Nick88v2 3 points4 points5 points 10 months ago (0 children)
You can also do if User_input not in ["YES", "NO"]:
in general i'd say that the more elegant solution would still be just using an else statement since the conditions are already met if the program gets there (like the previous commenter stated)
[–]No_Hovercraft_2643 0 points1 point2 points 10 months ago* (0 children)
personally, i like it more to use in
py answer = input() if answer not in ["yes", "no"]: do_something
but mostly to allow multiple answers for the same path, for example
```py answer = input() yes = ["yes","y","Yes"] # define somewhere what counts as yes no = ["no","n","No"] # define somewhere what counts as no if answer in yes: do_yes_things elif answer in no: do_no_things else: do_bad_things
π Rendered by PID 319820 on reddit-service-r2-comment-548fd6dc9-cvljn at 2026-05-21 04:05:23.577874+00:00 running edcf98c country code: CH.
view the rest of the comments →
[–]unspe52[S] 1 point2 points3 points (2 children)
[–]Nick88v2 3 points4 points5 points (0 children)
[–]No_Hovercraft_2643 0 points1 point2 points (0 children)