0
0
Pythonprogramming~20 mins

Continue statement behavior in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Continue Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of loop with continue inside if
What is the output of this Python code?
for i in range(5):
    if i == 2:
        continue
    print(i, end=' ')
Python
for i in range(5):
    if i == 2:
        continue
    print(i, end=' ')
A1 3 4
B0 1 2 3 4
C0 1 3 4
D0 1 2 3
Attempts:
2 left
💡 Hint
Remember, continue skips the rest of the current loop iteration.
Predict Output
intermediate
2:00remaining
Continue in nested loops
What will be printed by this code?
for i in range(3):
    for j in range(3):
        if j == 1:
            continue
        print(f"{i},{j}", end=' ')
Python
for i in range(3):
    for j in range(3):
        if j == 1:
            continue
        print(f"{i},{j}", end=' ')
A0,0 1,0 2,0
B0,0 0,2 1,0 1,2 2,0 2,2
C0,1 1,1 2,1
D0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2
Attempts:
2 left
💡 Hint
Continue skips printing when j equals 1.
Predict Output
advanced
2:00remaining
Continue with else clause in loop
What is the output of this code?
for i in range(3):
    if i == 1:
        continue
    print(i)
else:
    print('Done')
Python
for i in range(3):
    if i == 1:
        continue
    print(i)
else:
    print('Done')
A
0
2
Done
BDone
C
0
2
D
0
1
2
Done
Attempts:
2 left
💡 Hint
The else block runs after the loop finishes normally.
Predict Output
advanced
2:00remaining
Continue inside while loop
What will this code print?
i = 0
while i < 5:
    i += 1
    if i == 3:
        continue
    print(i, end=' ')
Python
i = 0
while i < 5:
    i += 1
    if i == 3:
        continue
    print(i, end=' ')
A2 3 4 5
B1 2 3 4 5
C1 2
D1 2 4 5
Attempts:
2 left
💡 Hint
Continue skips printing when i is 3.
Predict Output
expert
3:00remaining
Continue with multiple conditions and loop control
What is the output of this code?
result = []
for x in range(1, 6):
    if x % 2 == 0:
        continue
    if x == 5:
        break
    result.append(x)
print(result)
Python
result = []
for x in range(1, 6):
    if x % 2 == 0:
        continue
    if x == 5:
        break
    result.append(x)
print(result)
A[1, 3]
B[1, 3, 5]
C[1, 3, 5, 7]
D[2, 4]
Attempts:
2 left
💡 Hint
Continue skips even numbers, break stops loop at 5.