I have a program, which generates a python program as a string which I then need to execute. However, when I try running the string it throws a syntax error.
For example:
program = "self.move() self.turnRight() if x > 0: self.turnLeft() else: self.turnRight()"
eval(program)
when this runs a syntax error is thrown at whatever the second command is. I'm assuming this is because the string lacks tabs or newlines. Is there a way to automatically add these when the string goes through the eval command?