0

Wondering how would the following for loop be changed to while loop.

While having the same output.

for i in range(0,20, 4):
     print(i)

4 Answers 4

1

as simple as that:

i = 0
while i < 20:
    print(i)
    i += 4
Sign up to request clarification or add additional context in comments.

Comments

1
i = 0
while i < 20:
    print(i)
    i += 4

Comments

0

It will be something like this:

i = 1
while i < 20:
  print(i)
  i += 4

you can also visit here for more info: https://www.w3schools.com/python/python_while_loops.asp

Comments

0
i=0
while(i<5):
    print(4*i)
    i+=1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.