Eval problem in python

I am making a simple calculator
I am using the eval function.
When I use it, it doesn’t only give the expression’s value.
It, when given proper python code, executes it.
How to avoid it.

possible solution 1: don’t use eval

possible solution 2: validate the input before giving it to eval

Any alternatives to eval?

write the logic explicitly for each button

like if 5 is pressed, then * and then 5, write the logic to make that multiplication

It is actually by asking input. No GUI.

make rigid rules

take for example the Arithmetic Arranger project, there it requires sometimes to calculate the result, it is trivial to do from the input (ex. “123 + 5”)

Okay thanks for answering.