Skip to content

Commit 5ddeed7

Browse files
committed
Calculator bugfixes
1 parent 65a5ffe commit 5ddeed7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

calculator/api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .calculator_api import Calculator
1+
from .calculator_api import *

calculator/api/calculator_api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def add_digit(self, digit: str | int):
110110
self.equation_last += str(digit)
111111

112112

113-
def set_operator(self, operator: Operator):
113+
def set_operator(self, operator: Operator | str):
114114
"""Sets the operator of the equation. Also changes the current number to the second one.
115115
116116
>>> calc = Calculator()
@@ -121,7 +121,10 @@ def set_operator(self, operator: Operator):
121121
>>> calc.get_equation()
122122
'2 - 4'
123123
"""
124-
self.equation_type = operator.value
124+
if operator is Operator:
125+
self.equation_type = operator.value
126+
else:
127+
self.equation_type = operator
125128
self.current_part = "last"
126129

127130

0 commit comments

Comments
 (0)