← All flashcard decks Study now
beginner📚 4 cards
Python Loops
Master for loops, while loops, range(), break, and continue.
01
What does range(5) return?
Numbers 0, 1, 2, 3, 4 (5 is exclusive).
for i in range(5):
print(i)02
What does the break statement do?
Exits the loop immediately.
for i in range(10):
if i == 5: break03
What does the continue statement do?
Skips the current iteration and moves to the next.
for i in range(6):
if i % 2 == 0: continue
print(i)04
When to use while vs for?
Use for when you know the count. Use while when you repeat until a condition changes.
Ready to study?
Open the flashcards directory