From b329a87391cddc41a5f31af9b51c46839408a9cc Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Tue, 30 Sep 2025 15:00:29 -0700 Subject: [PATCH] Update wordy.py --- wordy/wordy.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/wordy/wordy.py b/wordy/wordy.py index 1766bb9..46ec339 100644 --- a/wordy/wordy.py +++ b/wordy/wordy.py @@ -74,20 +74,20 @@ def _math_operation(question: list[str]) -> int: :rtype: int """ math_operator: str = question[1] - result: int = 0 if math_operator == "+": - result = int(question[0]) + int(question[-1]) - elif math_operator == "-": - result = int(question[0]) - int(question[-1]) - elif math_operator == "/": - result = int(question[0]) // int(question[-1]) - elif math_operator == "*": - result = int(question[0]) * int(question[-1]) - else: - raise ValueError("syntax error") + return int(question[0]) + int(question[-1]) + + if math_operator == "-": + return int(question[0]) - int(question[-1]) + + if math_operator == "/": + return int(question[0]) // int(question[-1]) + + if math_operator == "*": + return int(question[0]) * int(question[-1]) - return result + raise ValueError("syntax error") def _validate_evaluation_pattern(val: list[str]) -> None: