def calculator(): while True: operation = input("What operation would you like to perform (+, -, *, /): ") if operation not in ["+", "-", "*", "/"]: print("Invalid operator, please use +, -, *, / only.") continue num1 = float(input("Enter the first number: ")) num2 = float(input("Enter the second number: ")) if operation == "+": print(num1 + num2) elif operation == "-": print(num1 - num2) elif operation == "*": print(num1 * num2) elif operation == "/": if num2 == 0: print("Cannot divide by zero.") continue print(num1 / num2) repeat = input("Would you like to perform another calculation? (y/n): ") if repeat.lower() != "y": break calculator()
top of page
bottom of page
Great....This code is running perfectly🐞