r/pythonhelp • u/[deleted] • Dec 07 '21
HOMEWORK Limiting user input to a number range
b = int(input("boiling point: "))
p = (5*b-400)
if (p > 100):
print(p)
print(1)
elif (p == 100):
print(p)
print(0)
else:
print(p)
print(-1)How can I allow the user to only input an integer from 80 (including 80) to 200 (including 200). Thanks!
3
Upvotes
4
u/Goobyalus Dec 07 '21
You can use a loop to keep asking until you get valid input: