Limit between 0 and 100
chemicalclothing at temple.edu
chemicalclothing at temple.edu
Sat Oct 25 16:42:08 EDT 2008
Hi. I'm very new to Python, and so this is probably a pretty basic
question, but I'm lost. I am looking to limit a float value to a
number between 0 and 100 (the input is a percentage).
I currently have:
integer = int()
running = True
while running:
try:
per_period_interest_rate = float(raw_input("Enter per-period
interest rate, in percent: "))
break
except ValueError:
print "Please re-enter the per-period interest rate as a number
between 0 and 100."
I also have to make sure it is a number and not letters or anything.
Thanks for the help.
James
P.S. I don't understand a lot of what I have there, I got most of it
from the beginning tutorials and help sections. I have never
programmed before, but this is for a school assignment.
More information about the Python-list
mailing list