Skip to content

Commit 6029d7d

Browse files
authored
Merge pull request #188 from ikostan/main
Merge from master
2 parents 9f1c925 + bc679b4 commit 6029d7d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

wordy/wordy.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,20 @@ def _math_operation(question: list[str]) -> int:
7474
:rtype: int
7575
"""
7676
math_operator: str = question[1]
77-
result: int = 0
7877

7978
if math_operator == "+":
80-
result = int(question[0]) + int(question[-1])
81-
elif math_operator == "-":
82-
result = int(question[0]) - int(question[-1])
83-
elif math_operator == "/":
84-
result = int(question[0]) // int(question[-1])
85-
elif math_operator == "*":
86-
result = int(question[0]) * int(question[-1])
87-
else:
88-
raise ValueError("syntax error")
79+
return int(question[0]) + int(question[-1])
80+
81+
if math_operator == "-":
82+
return int(question[0]) - int(question[-1])
83+
84+
if math_operator == "/":
85+
return int(question[0]) // int(question[-1])
86+
87+
if math_operator == "*":
88+
return int(question[0]) * int(question[-1])
8989

90-
return result
90+
raise ValueError("syntax error")
9191

9292

9393
def _validate_evaluation_pattern(val: list[str]) -> None:

0 commit comments

Comments
 (0)