Break Statement

break គឺ​ជា statement ដែល​ជា​បញ្ជា​តំរូវ​អោយ​បញ្ឈប់​ជា​បន្ទាន់​នូវ​ការអនុវត្ត block នៃ statement នៅ​ក្នុង statement for ឬ statement while ។

resume = {'name':'Kosal', 'last name':'Keo', 'age':35, 'address':'Cambodia'}
b = 0
for ele in resume:
    b += 1
    if b == 3:
        break

    print('The value attached to the key', ele, 'is', resume[ele])

while True:
    b += 1
    print('b is the number', b)
    if b == 10:
        break
The value attached to the key name is Kosal
The value attached to the key last name is Keo
b is the number 4
b is the number 5
b is the number 6
b is the number 7
b is the number 8
b is the number 9
b is the number 10