+ 2

Ive been wondering why this happens in python. v v v v

input:: num="print('Hello1')" print(num) output:: print('Hello1') For some reason the print command isnt running after compiling. Is there a way to make this work as intended? Desired Output:: Hello1

26th Jun 2018, 7:30 PM
Evan Martine
4 Antworten
+ 9
Perhaps you mean to actually "execute" the command in question? You should use exec() or eval() for that: https://code.sololearn.com/cPkjqOVhEGgc/?ref=app
26th Jun 2018, 9:11 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
num="Hello1" print(num)
26th Jun 2018, 7:32 PM
ReimarPB
ReimarPB - avatar
+ 2
@ReimarPB , I am trying to make the in-line print statement execute so that Hello1 is printed to the screen. I want to know why, after having run the code python doesnt see "print(Hello1)" and print Hello1 to the screen.
26th Jun 2018, 7:46 PM
Evan Martine
+ 1
So if I wanted to have a string of inline code like print(print(print('hello'))) I would have to put exec infront of it?
27th Jun 2018, 1:28 PM
Evan Martine