The "wait()" command is useful if we wish the robot to wait for a specific amount of time, but if we wish for our robot to wait until a given condition is met, we need to be a bit more inventive.
- 11 Jun 2020
The "pass" serves as an empty that can be placed in the "while" operator. This way the loop operator will repeat without executing any code until the condition becomes false.
Here's what this should look like in your code:
while condition: pass (code that doesn't execute until the condition is false)
Written like this, the code will await the condition of the "while" operator to become false in order to continue. In order for it to wait for the condition to be met, the "not" operator should be applied:
while not condition: pass (code that will execute when the condition is met)
This way the robot will wait for the condition of the "while" operator to become true before continuing with the program.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons