There is such code:
exp = input ('Expression: ').split(' ') for sim in exp: print (sim) if sim == '*': num1 = int ( exp[ exp.index(sim) - 1 ] ) num2 = int ( exp[ exp.index(sim) + 1 ] ) del exp[ exp.index(sim) - 1 ] del exp[ exp.index(sim) + 1 ] exp[ exp.index(sim) ] = num1 * num2 print (exp) An expression of the form "2 + 2 * 3 * 4" is entered into the input. Prototic, this line is divided into parts through spaces ( slpit(' ') ). Next in the resulting list is the search for the multiplication symbol (*). When it is found, its neighboring values ​​are deleted, and it changes to the product of those values. After that, I need to sort out the values ​​from the very beginning, as this example: "2 + 2 * 3 * 4" - my program will turn into "2 + 6 * 4". (Skip the next multiplication symbol.)
eval(exp)and that's it. Why invent something - Twisseval;) - MaxU