```
operator = ['+', '-', '/', '*', '']
class calculator:
def addition(x,y):
added = int(x) + int(y)
print(added)
def subtraction(x,y):
sub = int(x) - int(y)
print(sub)
def multiplication(x,y):
mult = int(x)*int(y)
print(mult)
def division(x,y):
#Doing a try on the division function in calculator class
try:
y = int(y)
x = int(x)
except ValueError:
print("Cannot divide, because either first or second number \
is not an integer.")
div = int(x)/int(y)
print(div)
while True:
'''See if input is a number. Inputs are turned into integers at assignment
for math that follows.'''
x = input("Enter first number")
y = input("Enter second number")
z = input("Enter an operator. (*, /, +, -)")
#Check if z in the list operator, if not then
if z not in operator:
print("No valid operator detected.")
for n in operator:
if z == '+':
print("Answer is... ")
calculator.addition(x, y)
if x == 0 and y == 0:
print("Answer is 0, because either first or second \
number was incorrect type.")
print(x)
print(y)
break
elif z == '*':
print("Answer is... ")
calculator.multiplication(x,y)
if x == 0 and y == 0:
print("Answer is 0, because either first or second \
number was not an integer.")
print(x)
print(y)
break
elif z == '/':
#the if statement was removed on this elif, but it now says that y is not defined
print("Answer is... ")
print(x)
print(y)
calculator.division(x,y)
break
elif z == '-':
print("Answer is... ")
calculator.subtraction(x,y)
if x == 0 and y == 0:
print("Answer is 0, because either first or second \
number was not an integer.")
break
```

Error with input āasfasdā for second number input

```
Traceback (most recent call last):
File "D:\Documents\Python Scripts\class example.py", line 62, in <module>
calculator.division(x,y)
File "D:\Documents\Python Scripts\class example.py", line 22, in division
div = int(x)/int(y)
ValueError: invalid literal for int() with base 10: 'asfasd'
```

I want it to be able to do try and except within each function of the calculator class, and give a unique message if it errors within those functions. For now, Iāve been testing divide, but it apparently doesnāt want to make the number into an integer, even though I told it to convert when it arrived at the class.

If I convert it at input, it still just errors āinvalid literalā if I were to input a non-int. I donāt want the program to crash, but tell the user to put proper input in.