I basically want my code to find the solution to the expression through brute force. I would prefer my code look like this:
def broot():
x = 0
probleft = 3*x - 7
probright = 3 - 2*x
for i in range (10):
x = x + 1
if probleft == probright: print(x) x = x - x break
But the obvious problem is that probleft and probright don't recalculate themselves after the value of x changes. And I cant just define them again, because the program is supposed to BE a calculator. So it would be a nightmare to enter the expression multiple times, especially after I update the program to be compatible with other types of expressions. So I cant do this:
def broot():
x = 0
for i in range (10):
probleft = 3*x - 7
probright = 3 - 2*x
x = x + 1
if probleft == probright: print(x) x = x - x break
Because probleft and probright will be used in several more places in the program.