← Go Back
This function has no return value.
How to Execute Python Code Contained in a String
Using theexec()
built-in function, which takes a string that must contain Python code.>>> code = "print('Hello, world.')"
>>> exec(code)
Hello, world.
This function has no return value.
🐍 You might also find interesting: