Py Loops — Free Python Tutorial
Learn Py Loops in Python with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.
TL;DR: Learn Py Loops in Python with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.
Written & reviewed by the Syllab.in Academic Team (CBSE/NCERT subject experts) · Updated
Py Loops in Python
Loops let you repeat code. Python has two types: for loops (iterate over a sequence) and while loops (repeat while a condition is True).
The range() function generates a sequence of numbers: range(5) → 0,1,2,3,4. range(1,6) → 1,2,3,4,5. range(1,10,2) → 1,3,5,7,9. Very commonly used with for loops.
break exits the loop immediately. continue skips to the next iteration. for/while loops can have an else block that runs only if the loop completed without a break.
Py Loops — Syntax
for item in sequence:
# repeats for each item
for i in range(n):
# repeats n times (0 to n-1)
while condition:
# repeats while True
Learn Py Loops step by step with Syllab's free interactive Python tutorial — runnable code examples, practice exercises and instant AI feedback, all free with no signup. Explore the full Python course →