Select Page

ABIOLA RASP – Raspberries for African School Projects

Wie können wir helfen?

< Alle Themen

Python – while loop

no-166 au-04

Phyton „while“ loop

The while loop executes the code as long as the condition of the statement in the head of the loop is logically true. If the evaluation leads to a result that is false right at the beginning, the loop will not be executed at all. Below you can see the general syntax for a while loop.

  1. The while loop is executed as long as the expression i < 3 is true.
  2. The numbers from 1 to 3 are printed in the debug window.

You have to make sure with such statements that it really comes to a loop termination at some point. In the worst case it becomes an infinite loop that stops the CPU.

Zurück Python – String variables