- Loops: Master
forandwhileloops for iteration.
Loops allow us to repeat a block of code multiple times. Two common types are:
-
forLoop:for i in range(5):
print(f”Count: {i}”)//This loop will print numbers from 0 to 4.
whileLoop:
num = 1
while num <= 10:
print(num)
num += 1
// This loop will print numbers from 1 to 10.
