I'm a fairly beginner coder and I'm working on a project of mine, although I'm having trouble, I've looked online for anything that can help but I can't seem to be able to do it. I'm trying to create a program that solves algebriac equations, I've managed to split the whole string into two lists, I can then join the lists together but it only prints as a string, I can't print it as a float or an integer.
import re
group1 = []
group2 = []
subjects = []
question = input("What is the question?")
questions = list(question)
for i in range(len(questions)):
if questions[i] == "=":
for a in range(i):
group1.append(questions[a])
print(group1)
a = a + 2
for b in range(a,len(questions)):
group2.append(questions[b])
print(group2)
for i in range(len(group1)):
if re.match("[a-z]", str(group1[i])):
subjects.append(group1[i])
print(subjects)
for i in range(len(group2)):
if re.match("[a-z]", str(group2[i])):
subjects.append(group2[i])
pair1 = ''.join(group1)
pair2 = ''.join(group2)
print(int(pair1))
print(pair2)
(This of course isn't finished)
When it tries to print (int(pair1))
, I get this error:
ValueError: invalid literal for int() with base 10: '5+6'
I need help to overcome this.