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
  • 158,107
  • 27
  • 234
  • 292

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,049
  • 1
  • 5
  • 21