1#in Python, break statements can be used to break out of a loop
2for x in range(5):
3 print(x * 2)
4 if x > 3:
5 break
1number = 0
2
3for number in range(10):
4 if number == 5:
5 break # break here
6
7 print('Number is ' + str(number))
8
9print('Out of loop')
1# Use of break statement inside the loop
2
3for val in "string":
4 if val == "i":
5 break
6 print(val)
7
8print("The end")
9---------------------------------------------------------------------------
10s
11t
12r
13The end
1nums = [6,8,0,5,3]
2product = 1
3
4for num in nums:
5 if num == 0:
6 product = 0
7 break # stops the for loop
8 product *= num
9
10print(product)