Current location - Recipe Complete Network - Catering training - How to limit the number of while cycles of Zhong Ming robot express train
How to limit the number of while cycles of Zhong Ming robot express train
The While cycle of the Zhong Ming robot express train can use counters to limit the number of while cycles, for example:

1、Copycount=0whilecount2、

3. In the above code, the count variable is used for counting, with an initial value of 0. Every time a loop is executed, 1 is added, and when the value of count reaches 5, the loop will stop.

2、

3. You can modify the initial value and limit conditions of the counter as needed. A while loop is a loop structure that repeatedly executes a piece of code until the specified conditions are no longer met.