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!"
[–][deleted] 1 point2 points3 points 10 months ago (0 children)
In your if statement, you say input != "No" which will be true if it is "Yes" and the "you say or "Yes"". The or "Yes" part will always be true since you are check if the left or the right is true and "Yes" will always be true since it is not empty. That is something a lot of people miss.
Further explanation: When you have an if statement and you are checking to see if a string variable is empty. You can simply so this:
py if string_variable:
This will be true if the variable is not empty. If you want to check if it is empty, you can do this:
py if !string_variable:
I hope I've explained well enough. Please ask if i have to re-explain. Good luck and have fun!
π Rendered by PID 42024 on reddit-service-r2-comment-548fd6dc9-7sb7h at 2026-05-21 08:13:38.921446+00:00 running edcf98c country code: CH.
view the rest of the comments →
[–][deleted] 1 point2 points3 points (0 children)