The exec()
function executes the specified Python code.
The exec()
function accepts large blocks of code, unlike the eval()
function which only accepts a single expression
x = 'name = "John"\n print("Hello, " + name)'
exec(x)
x = 'print("2+3=", 2+3)'
eval(x)
console.log(eval('2 + 2'));
// Expected output: 4
No comments:
Post a Comment