0

I would like to know it it is possible to convert a string made of numbers and symbols into actual numbers an symbols, for example '(12+23)*4' into (12+23)*4 script:

input = input('import calculation: ')

print(input)

Output ex:

3*5

Desired Output ex:

15

Thanks!

xtekky
  • 228
  • 1
  • 10

1 Answers1

-2

you can use eval function directly, even if it's not recommended for security concerns.

eval(input('import calculation: '))

One more advice, do not name your variable as builtin function or imported ones, you're crrently doing monkey patching.

Félix Herbinet
  • 237
  • 1
  • 6