All lessons
πŸ”

Loops: for & while

Repeat work efficiently using for and while loops.

Control Flow 15 min +50 XP

for loop

Iterate over a sequence such as a list or a range of numbers.

for i in range(3):
    print("Hi", i)

while loop

Runs as long as the condition is True.

n = 3
while n > 0:
    print(n)
    n -= 1

break & continue

break exits the loop early. continue skips to the next iteration.

If / Elif / Else