Ok so I am completely new to coding, I was making a simple calculator and I came across an error called ZeroDivisionError and I tried really hard to handle it as an exception but I couldn't. It would be really nice if someone could help me with this. Thanks! Here is the code:
def multiply(first_number, second_number):
print("The Number = ", int(first_number) * int(second_number))
def divide(first_number, second_number):
print("The Number = ", int(first_number) / int(second_number))
def add(first_number, second_number):
print("The Number = ", int(first_number) + int(second_number))
def sub(first_number, second_number):
print("The Number = ", int(first_number) - int(second_number))
def start():
first_number = input("Insert first number: ")
second_number = input("Insert second number: ")
type = input("You wanna (+)Add, (-)Subtract, (/)Divide or (x)Multiply? ")
if type == "+":
add(first_number, second_number)
elif type == "-":
sub(first_number, second_number)
elif type == "/":
divide(first_number, second_number)
elif type == "x":
multiply(first_number, second_number)
else:
print("There is no such thing as", type, "!")
start()
confirm = input("Do you want to exit the program? (Y)es/(N)o? ")
if confirm == "N":
start()
elif confirm == "Y":
print("You quit the program.")
else:
print("There is no such thing as", confirm, "!")
start()