# Add, Subtract, Multply, Divide with Functions
# Add Function
def add():
num1 = int(input("\nEnter 1st Number: "))
num2 = int(input("Enter 2nd Number: "))
answer = num1 + num2
return answer
# Subtract Function
def subtract():
num1 = int(input("\nEnter 1st Number: "))
num2 = int(input("Enter 2nd Number: "))
answer = num1 - num2
return answer
# Multiply Function
def multiply():
num1 = int(input("\nEnter 1st Number: "))
num2 = int(input("Enter 2nd Number: "))
answer = num1 * num2
return answer
# Divide Function
def divide():
num1 = int(input("\nEnter 1st Number: "))
num2 = int(input("Enter 2nd Number: "))
answer = num1 / num2
return answer
# Main
print("---------------")
print("| |")
print("|1. ADD |")
print("|2. Subtract |")
print("|3. Multiply |")
print("|4. Divide |")
print("| |")
print("---------------")
# Choice Variable
choice = int(input("Please choose a number (1-4): "))
# Choice Loop
if (choice == 1):
print("\nThe answer is: ", add())
elif (choice == 2):
print("\nThe answer is: ", subtract())
elif (choice == 3):
print("\nThe answer is: ", multiply())
elif (choice == 4):
print("\nThe answer is: ", divide())
if (choice != '1', '2', '3', '4'):
print("\nError: Invalid Number, Restart and Try Again.")
continue
# Check If User Wants Another Calculation
nextcalc = input("Do you want to do another calculation (yes/no): ")
if nextcalc == "no":
break
else:
print("Program Ending..")
I am trying to get it so when done it asks the user if they want to do another calculation and if yes then to ask what type of calculation and then numbers input, and if no then end the program. Also if anything besides 1-4 is entered I want it to ask the user again for their choice.