I am new to Python and I was trying to train on reeborg website and it went fine، but on hurdle 4 I tried everything I know but The bot still does not working well
This is my code:
def turn_right():
turn_left()
turn_left()
turn_left()
while not at_goal():
if front_is_clear():
while front_is_clear():
if not wall_on_right():
turn_right()
move()
turn_right()
move()
if wall_on_right():
turn_left()
else:
if not wall_on_right():
turn_right()
move()
turn_right()
if wall_on_right():
turn_left()
while wall_on_right():
move()
Can someone help me?
Watch your program execute: the error occurs when Reeborg reaches the top of the world and the world border, which is a wall, messes up with you logic. You are trying to do too many things in a complex set of if/while conditions.
Break your code into more separate functions, each function containing either a single if/else set of instructions, or a single while loop.
Try then to string together the following general step:
Repeat steps 1 to 4 until you reach the goal.