๐Ÿ“˜ Chapter 7: Loops in Python


๐Ÿ” What Are Loops?

Loops are used to repeat a block of code multiple times efficiently. Instead of writing the same thing 100 times, you tell Python:

โ€œRun this 100 times!โ€ and it says โ€œSure!โ€.

There are 2 main types of loops in Python:

Loop Type When to Use
for loop When you know how many times to repeat something
while loop When you want to repeat until a condition is false

๐ŸŒ€ for Loop โ€“ The Repeater You Trust

for i in range(1, 101):
    print(i)

๐Ÿ“ Print Name Multiple Times

for i in range(10):
    print("Prathamesh")

๐Ÿงฎ Range Syntax Breakdown