0

I want to have a program that can take user input (such as the input(__prompt__) code) and execute it as if it were part of the actual code.

Example:

Python: What code would you like to run? User: print('Hello world') Python: Hello world

I don't even know if this is possible or not but it would really be nice.

tripleee
  • 175,061
  • 34
  • 275
  • 318

1 Answers1

0

Use exec(). However, if this project is using sensitive information, be warned that a user can access anything with this script.

exec(input(">>> "))
Seth
  • 2,214
  • 1
  • 7
  • 21