Creating a function that takes an equation given as a string and computes it [duplicate]
This question already has answers here : Evaluating a mathematical expression in a string (11 answers) Closed 4 years ago . As part of an assignment, I am creating a function that takes in a string, which is an equation. here is an example of one: 48+6x6/3=6x8-9x2. The compute function takes one side of the equal sign and evaluates it. I am not too concerned with splitting the equation. I believe I can just slice it with s[:s.find("=")] . My main problem is the compute function itself. I will post where I am with it so far. The commented out part was stuff I was trying to deal with double