diff --git a/mathgenerator/funcs/algebra/expanding.py b/mathgenerator/funcs/algebra/expanding.py index e93071b..0e75b16 100644 --- a/mathgenerator/funcs/algebra/expanding.py +++ b/mathgenerator/funcs/algebra/expanding.py @@ -24,20 +24,22 @@ def expandingFunc(range_x1=10, range_x2=10, range_a=10, range_b=10): p3 = intParser(b) p4 = intParser(x2) + if p1 == "+1": p1 = "" - if p1[0] == "+": + elif len(p1) > 0 and p1[0] == "+": p1 = p1[1:] if p3 == "+1": p3 = "" - if p3 == "+": + elif p3 == "+": p3 = p3[1:] problem = f"({p1}x{p2})({p3}x{p4})" if c1 == "+1": c1 = "" - if c1[0] == "+": + elif len(c1) > 0 and c1[0] == "+": c1 = c1[1:] # Cuts off the plus for readability + if c2 == "+1": c2 = "" solution = f"{c1}*x^2{c2}*x{c3}"