How to use Loop to print numbers 8,11,14,17,......83,86.
for i in range(100):
i = 8
print(i+3)
but this do not works
How to use Loop to print numbers 8,11,14,17,......83,86.
for i in range(100):
i = 8
print(i+3)
but this do not works
You are not updating your variable i
. This loop will print i+3
(which is 11 of course) 100 times and does not update i
.
As already mentioned, you can use the following code:
for i in range(8, 87, 3):
print(i)
range
will provide you with a range object (which is a kind of iterable) with all numbers between 8 and 86 with a step size of 3 (so 8, 11, 14, ...)