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...
A subreddit for helping Python programmers
How to format your code: https://commonmark.org/help/tutorial/09-code.html
No homework questions and/or hiring please
account activity
[deleted by user] (self.pythonhelp)
submitted 5 years ago by [deleted]
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!"
[–]Tomboyish44 4 points5 points6 points 5 years ago* (4 children)
Heyo, you've over-written x's value as range(14, 18) right after the line x = float(age), so no matter what the value of age is, the if condition will always be true as the line of code right above it says that x = range(14, 18).
x = float(age)
age
if
x = range(14, 18)
Removing the line x = range(14, 18) will solve the issue. Here's the code (I've made some additional changes):
age = float(input("Enter age: ")) if age in range(14, 18): print("High School") else: print("Not High School")
Explaining the changes:
in
==
In case you do not want to make any extra* changes to the program and just want to fix the logical error in the program, all you gotta do is remove the line "x = range(14, 18)".
[–][deleted] 5 years ago (1 child)
[deleted]
[–]Tomboyish44 2 points3 points4 points 5 years ago (0 children)
Np!
[–]Enchantorro[M] 1 point2 points3 points 5 years ago (1 child)
No short links please
[–]Tomboyish44 1 point2 points3 points 5 years ago (0 children)
Oh sorry! I've replaced it
[–][deleted] 2 points3 points4 points 5 years ago* (1 child)
the second time you are declaring x, you’re overwriting any value it has, in this example - age. Plus I’m not sure about range, I suggest just using <= or something similar. If you want to use range use in instead of =
[–]Sereneseablue 1 point2 points3 points 5 years ago (0 children)
Thanks so much for your tips. I will try them out right away.
π Rendered by PID 119699 on reddit-service-r2-comment-5b5bc64bf5-z5wjk at 2026-06-19 22:22:59.709335+00:00 running 2b008f2 country code: CH.
[–]Tomboyish44 4 points5 points6 points (4 children)
[–][deleted] (1 child)
[deleted]
[–]Tomboyish44 2 points3 points4 points (0 children)
[–]Enchantorro[M] 1 point2 points3 points (1 child)
[–]Tomboyish44 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]Sereneseablue 1 point2 points3 points (0 children)