I'm trying to add validation to my application in Python.
Basically I want to make sure their input is a number and if its not, it should just keep asking them the input question until they get it.
This is what I got which only works for like 2 tries, I believe its because it checks if its not null.
I know this is a lot of code. Not sure of another way to do this, any ideas?
while amount != "":
try:
val = int(amount)
while counter < int(amount):
counter = counter + 1
ran = ran + 1
num3 = input(str(ran) + ". Input: ")
try:
val = int(num3)
except ValueError:
num3 = input(str(ran) + ". Input: ")
numbers.append(num3)
print("")
home()
except ValueError:
amount=input("How many numbers are in your list? ")
while counter < int(amount):
counter = counter + 1
ran = ran + 1
num3 = input(str(ran) + ". Input: ")
try:
val = int(num3)
except ValueError:
num3 = input(str(ran) + ". Input: ")
numbers.append(num3)
print("")
home()
homefunction do?