I have a string 'user = input("Hello World")'
. How can I execute the string to be able to run as a python command?
I am a new to python so I must have missed the basic syntax. please help me instead of routing me to another answer
I have a string 'user = input("Hello World")'
. How can I execute the string to be able to run as a python command?
I am a new to python so I must have missed the basic syntax. please help me instead of routing me to another answer
You can use either of two exec
or eval
to run the string as python command based on your desired syntax or result
eval('user = input("Hello World")')
exec('user = input("Hello World")')