Removed . from operators, remade line 17
This commit is contained in:
4
calc.py
4
calc.py
@@ -14,9 +14,7 @@ def calc(text):
|
|||||||
expression = ""
|
expression = ""
|
||||||
should_calc = False
|
should_calc = False
|
||||||
for char in text:
|
for char in text:
|
||||||
if char.isdigit() or (should_calc and char in [".", " "]):
|
if char.isdigit() or (expression and char == ".") or (should_calc and char == " "):
|
||||||
expression += char
|
|
||||||
elif expression and char == ".":
|
|
||||||
expression += char
|
expression += char
|
||||||
elif char in math_operators:
|
elif char in math_operators:
|
||||||
# calculation must include at least 1 operator
|
# calculation must include at least 1 operator
|
||||||
|
|||||||
Reference in New Issue
Block a user