Limit between 0 and 100
benjamin.kaplan at case.edu
Sat Oct 25 23:17:52 CEST 2008
On Sat, Oct 25, 2008 at 4:42 PM, <chemicalclothing at temple.edu> wrote:
> 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.
look up conditionals (specifically if statements) in the Python tutorial. If
you still can't figure it out, ask on the Python Tutor list. This list is
for questions about python, not for questions about how to program.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list