I am writing python code for algebraic expansion and I am running into a major error, python is not able to recognize the existence of a conditional it seems and I cannot figure out why
The code is:
def This(String):
ReturnList = [char for char in String]
Returner = []
Counter = 0
while len(ReturnList) > 1:
TempString = ""
for x in range(len(ReturnList)):
Counter += 1
if ReturnList[x] != "+" or ReturnList[x] != "-":
print(ReturnList[x])
TempString += str(ReturnList[x])
else:
break
for x in range(Counter):
ReturnList.pop(0)
Returner.append(TempString)
Counter = 0
return Returner
here = "a^3 + 3a^2b + 3ab^2 + b^3"
print(here)
print(This(here))
The code is suppose to take the string, and then return sections of it, like this:
["+a^3","+3a^2b","+3ab^2","+b^3"]
however it doesnt seem to recognize + or - in the list, and just ignores it to return the full string
This is the print statements output:
a
^
3
+
3
a
^
2
b
+
3
a
b
^
2
+
b
^
3