Python. Robot. Bye loop


Checking the situation 

The robot has sensors that allow it to receive information about the environment.
Sensors determine, for example, whether there is a wall in a certain direction. To use the sensors, the robot must be given a special logical command.
 
Boolean command is a condition that can be true (true) or false (false).

Using logical commands, you can receive feedback from the robot and monitor changes in the environment around the robot.

In programming, there is a special cyclic construction that repeats actions until a condition is met.  This is called a conditional loop. In general, in Python, it can be written like this:
 
while boolean:
    team_1
    team_2
    ....

The execution of all commands will be repeated as long as the logical condition is met. If the logical condition is true (the sensor worked), then the commands written inside the structure will be executed for the time being. If the condition is not met, then the commands stop being executed and the loop ends. The following commands after the loop will be executed, if they are in the program.

The logical commands that the Silver robot knows are given below.
wall_top, wall_right, wall_bottom, wall_left.

You can check the opposite condition (for example, do something if the sensor did not work). In this case, before the logical condition, you must put the word not (logical negation - not). 
For example, the program

not yet wall_top:
    up

 
will make the robot walk up until it hits a wall from above. The robot will stop near the wall.