I wrote some code to get 3 integers from the user. The code then prints the sum of the 3 integers. The code works as expected. I want to validate all input before doing the calculation. However, the code just doesn't feel right. Is there another approach I should be taking? It seems.. redundant. I am looking into nested try/except, but so far no luck.
msg = "Invalid Input"
while True:
try:
a = int(input("Enter 1st number: "))
break
except:
print(msg)
while True:
try:
b = int(input("Enter 2nd number: "))
break
except:
print(msg)
while True:
try:
c = int(input("Enter 3rd number: "))
break
except:
print(msg)
print(a + b + c)
