Fix: add exception handling to calculate function #2

Merged
testclient-admin merged 1 commits from fix-calculator into main 2026-08-29 18:39:23 +00:00
+3
View File
@@ -1,4 +1,5 @@
def calculate(a, b, op):
try:
if op == '+':
return a + b
elif op == '-':
@@ -11,6 +12,8 @@ def calculate(a, b, op):
return a / b
else:
return "Ошибка: неизвестная операция"
except Exception as e:
return f"Ошибка: {e}"
while True:
expr = input("Введите выражение (или 'quit' для выхода): ")