Limit between 0 and 100

chemicalclothing at chemicalclothing at
Sat Oct 25 22:42:08 CEST 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:
    per_period_interest_rate = float(raw_input("Enter per-period
interest rate, in percent: "))
  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.


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