Articles → PYTHON → Break And Continue Statement In Python
Break And Continue Statement In Python
Break Statement
message = "This is the test message"
for character in message:
if character == " ":
break
else :
print("The value is ", character)
- Loop through all the characters in the string ‘This is the test message’
- If the blank space is found, then exit the loop
Continue Statement
message = "This is the test message"
for character in message:
if character == " ":
continue
else :
print("The value is ", character)