# Simple Calculator Program

def add(num1, num2):
    return num1 + num2

def subtract(num1, num2):
    return num1 - num2    

def calculator():
    while True: # A loop to allow multiple calculations
        try:

            # Get user input for two numbers
            num1 = float(input("Enter the first number: "))
            num2 = float(input("Enter the second number: "))

            # Get user input for the operation
            operation = input("Enter the operation (add/subtract): ").strip().lower()

            # Perform the chosen operation
            if operation == 'add':
                result = add(num1, num2)                
                print(f"The result of adding {num1} and {num2} is: {result}")
            elif operation == 'subtract':
                result = subtract(num1, num2)
                print(f"The result of subtracting {num2} from {num1} is: {result}")
            else:
                print("Invalid operation. Please enter 'add' or 'subtract'.")
        
            # Question to ask whether to continue or quit?
            again = input("Would you like to continue again? (yes/no):").strip().lower()
            if again != 'yes':
                break
        except ValueError:
            print("The input is not valid!!! Enter only numbers")

# Call the calculator function
calculator()
