Exercise: Terminate for-loop with break
Use a
break
statement to terminate the loop once total_sum reaches 20 points.numbers = (3,6,2,6,4,9,5,2)
total_sum = 0
for num in numbers:
total_sum += num
# add code here...
print(total_sum)
# expected output: 21
Python
Setting up Python environment...
Output