I'm trying to create string parser that can divide a mathematical equation into the different parts (numbers and operators). Right now, I'm trying to create a list to separate between the different parts.
Ex: ["123", "+", "123"]
However, I'm trying to do it in a way that doesn't require me to write spaces in the input. Instead of inputting: "123 + 123", I want to write: "123+123". How would I split the string between the addition sign and the number and append it to the list?
I'm aware that if I add a space between the "123+123", I would be able to split it, but my goal is to be able to split it without the spaces; just one big block of text.
So far, I've tried splitting it from the addition sign, but that just deletes it which leaves me with ["123", "123"]
equation = input("Equation: ")
>> Equation: 123+123
mylist = []
l.append(equation)
for x in mylist:
print(x.split("+"))
>> ["123", "123"]