+ 2
Is there a way for a Python program to create new variables, loops, etc within itself?
2 Respuestas
+ 2
Yes. You could literal prompt used for commands and execute them. Or generate code and execute that. The command you need is eval().
+ 2
You might have a look at the exec() function. [ Be careful to use that. ]
>> a = exec("for i in range(10): print(i)")