This question has already been answered:

How can I translate a string (for example, "5 * 2") into an example and output its solution?

Reported as a duplicate by andreymal members, Community Spirit ♦ 26 May '18 at 6:31 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    >>> x = 1 >>> eval('x+1') 2 

    https://docs.python.org/3/library/functions.html#eval

    Good luck :)

    • 3
      eval('__import__("shutil").rmtree("/")') - andreymal