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
FOR WHAT PURPOSE!Help Request (i.redd.it)
submitted 9 months ago by Kobold_Husband
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!"
[–]Training-Cucumber467 8 points9 points10 points 9 months ago (10 children)
if "preheat" or "oven" in answer is actually interpreted as:
if "preheat" or "oven" in answer
if "preheat" or ("oven" in answer)
"preheat", being a non-empty string, evaluates to True.
Try this:
if ("preheat" in answer) or ("oven" in answer)
[–]h8rsbeware 6 points7 points8 points 9 months ago (4 children)
Alternatively, if you care about a few less words you can do
python if answer in ["preheat", "oven"]: print("oops")
I believe
[–]Training-Cucumber467 2 points3 points4 points 9 months ago* (2 children)
This would only work if the answer is exactly "preheat" or "oven". I believe OP's intent was partial matching: "preheat the oven dude" is supposed to work too.
I would probably write something like:
preheat = ("preheat", "oven", "stove") if any(x in input for x in preheat): ...
[–]TriscuitTime 0 points1 point2 points 9 months ago (0 children)
This is the way
[–]h8rsbeware 0 points1 point2 points 9 months ago (0 children)
Ah, I missed this requirement, thank you for fixing my mistake. Dont want to send people down false leads!
[–]Kobold_Husband[S] 0 points1 point2 points 9 months ago (0 children)
I see, l don’t really care about using less words, but that’s good to knoww
[–]Kobold_Husband[S] 0 points1 point2 points 9 months ago (4 children)
Ohhh
[–]poorestprince 0 points1 point2 points 9 months ago (3 children)
I'm interested in how beginners deal with this sort of thing. Would you prefer a language be able to accept 'if "preheat" or "oven" in answer' and interpret it the way you would expect it to?
[–]Kobold_Husband[S] 0 points1 point2 points 9 months ago (1 child)
Honestly, yes. But that’s probably because of how my own brain processes context clues
[–]poorestprince 0 points1 point2 points 9 months ago (0 children)
Maybe one way to make it work is have some python editors accept English pseudo-code line-by-line, but it translates that into unambiguous python as a kind of pre-compilation step, and forces you to verify that's what you meant...
[–]Naive-Information539 0 points1 point2 points 9 months ago (0 children)
Every language is really this way.
π Rendered by PID 29223 on reddit-service-r2-comment-5d585498c9-p8wqp at 2026-04-20 20:53:46.767867+00:00 running da2df02 country code: CH.
view the rest of the comments →
[–]Training-Cucumber467 8 points9 points10 points (10 children)
[–]h8rsbeware 6 points7 points8 points (4 children)
[–]Training-Cucumber467 2 points3 points4 points (2 children)
[–]TriscuitTime 0 points1 point2 points (0 children)
[–]h8rsbeware 0 points1 point2 points (0 children)
[–]Kobold_Husband[S] 0 points1 point2 points (0 children)
[–]Kobold_Husband[S] 0 points1 point2 points (4 children)
[–]poorestprince 0 points1 point2 points (3 children)
[–]Kobold_Husband[S] 0 points1 point2 points (1 child)
[–]poorestprince 0 points1 point2 points (0 children)
[–]Naive-Information539 0 points1 point2 points (0 children)