-5

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

2
  • 5
    for i in range(8, 87, 3): print(i) Commented Jul 8, 2020 at 9:48
  • 1
    Does this answer your question? Python Sequence of Numbers Commented Jul 8, 2020 at 9:51

1 Answer 1

0

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, ...)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.