more calc improvements

This commit is contained in:
jomo
2015-01-02 01:28:39 +01:00
parent 0842d92187
commit 9110fc2eda

View File

@@ -14,7 +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 char in [".", " "]: if char.isdigit() or (should_calc and char in [".", " "]):
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