I am a real beginner with Python, although I am loving every minute of it so far.
I am making a little program that takes user input and then does stuff with it. My issue is that the numbers the user inputs have to
(1) All add up to not more than one (i.e. a1+ a2+ a3 \leq 1)
(2) Each individually be < 1.
Here is my code thus far (just the essential middle bit):
num_array = list()
a1 = raw_input('Enter percentage a (in decimal form): ')
a2 = raw_input('Enter percentage b (in decimal form): ')
...
an = raw_input('Enter percentage n (in decimal form): ')
li = [a1, a2, ... , an]
for s in li:
num_array.append(float(s))
And I would love to build in something to make it demand the user re-inputs things if their inputs either exceed the requirement that
a1+a2+a3 >1
or that a1>1, a2>1, a3>1 etc.
I have a feeling this would be really easy to implement, but with my limited knowledge I am stuck!
Any help would be much appreciated :-)