Python - For Loop
What is the output of this code?
for num in [1, 2, 3]:
if num == 4:
break
else:
print("No break encountered")What is the output of this code?
for num in [1, 2, 3]:
if num == 4:
break
else:
print("No break encountered")num == 4. Since 4 is not in the list, break never runs.break, the else block runs and prints "No break encountered".15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions