Reading Time: 1 minutes
Sum a List of Numbers with Exception Handling in Python: A simple Python program of adding 3 given numbers, handling exception in case user inputs anything other than digits.
Sum a List of Numbers with Exception Handling in Python
# Sum of 3 numbers
# A simple program of adding 3 given numbers, handling exception in case user inputs anything other than digits.
# asking for inputs
try:
numberOne = float(input("Please enter the first number: "))
numberTwo = float(input("Please enter the second number: "))
numberThree = float(input("Please enter the third number: "))
except ValueError:
print("That was not a number!")
# displaying total
try:
print("Total: ", str(numberOne + numberTwo + numberThree))
except NameError:
print("Cannot compute sum. Please execute the program again.")
Try it here.







