Explanation:
range(1, 10, 3)This means:
-
Start from 1
-
Go up to (but not including) 10
-
Step by 3 each time
So the values of i will be:
✅ So it loops over: 1, 4, 7
print(i, end=" ")
This prints each number on the same line, separated by spaces.
Final Output:
Summary:
This for loop prints numbers from 1 to 9, skipping 3 numbers each time, using a custom step of 3.


0 Comments:
Post a Comment