break is a keyword in python just like another programming language and it is used to break the execution of loop statement.
Example 1:
for i in range(1,11): if(i==6): break print(i)
Output
1 2 3 4 5
Example 2: In this example, we are printing character by character of the value/string “Hello world” and terminating (using break), if the character is space.
for ch in "Hello world": if ch == " ": break print(ch)
H e l l o
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Example 1:
Output
Example 2: In this example, we are printing character by character of the value/string “Hello world” and terminating (using break), if the character is space.
Output
need an explanation for this answer? contact us directly to get an explanation for this answer