The program below successfully asks a user to enter 2 numbers
and calculates
a mean. BUT, if the user enters something that isn't a number, the
program
crashes. Catch this error using a try/except block.
accum = 0
for i in range(2):
num = int(input("Enter your number:"))
accum = accum + num
mean = accum/2
print("The average is ",mean)
Code image:

Output image:


Code :
try:
x = int(input("Enter a number : "))
y = int(input("Enter a number : "))
mean = (x + y)/2
print("Mean : ", mean)
except ValueError:
print("Invalid input.")
Note :
Please follow indentation(spaces/tabs) according to the code image.
The program below successfully asks a user to enter 2 numbers and calculates a mean. BUT,...