Hi...I am new to programming, I'm trying out all kind of stuff and it is fun.
I just have this question about python..
x = "g = lambda x,y: x+y"
exec(x)
g(1,2) <----that will give me number 3.
f = "g(1,2)"
answer = exec "f"
why will this give me a syntax error? is there ways to assign "g(1,2)" as code not as string so I can execute it?
I just have this question about python..
x = "g = lambda x,y: x+y"
exec(x)
g(1,2) <----that will give me number 3.
f = "g(1,2)"
answer = exec "f"
why will this give me a syntax error? is there ways to assign "g(1,2)" as code not as string so I can execute it?