LearnFrenzy
Sign in Take a free test

Loops · Predict the Output · Question 3

Skipping multiples of 3 with continue Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

What is the output of the following Python program?

main.py
for i in range(1, 8):
    if i % 3 == 0:
        continue
    print(i, end=" ")
print()
  • A 1 2 4 5 7 Correct
  • B 1 2
  • C 3 6
  • D 1 2 3 4 5 6 7
Correct Answer: Option A

continue skips the print for 3 and 6 and moves on; it does not end the loop.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links