In a Python 'while' loop that is collecting user input, is there a way to put a condition on the last loop? The user determines the number of loops but I want to put a condtion on the last input to be greater or equal to 1.
I already have a general value error to ensure no inputs are string. I would want float inputs for the first x amount of inputs but then limit the last one to 1 or more.
while True:
try:
for x in range(itemNum):
globals ()['itemValue%s' % x] =float(input("Enter value for "+(globals()['itemName%s' % x])+(": ")))
except ValueError:
print("Sorry, Please enter only numbers. Try again.")
continue
else:
break