I have to count till 45 with increments of 3 using for loop only in python. I did it using while loop but I want to do it without the while loop?
for n in range(1):
while n < 45:
n = n + 3
print(n)
Use the range function with start stop and step parameters
for i in range(3,46,3):
print(i)
OUTPUT
3
6
9
12
15
18
21
24
27
30
33
36
39
42
45
range. Here it is.