Python break statement

Python break articulations, as in C, break the insignificant shut for or while circle.

The break articulation is utilized to end the circle proclamation. That is, if the circle condition has no False condition or the succession has not been totally recursed, the circle proclamation will be halted.

The break articulation is utilized in the while and for circles.

In the event that you use settled circles, the break explanation will quit executing the most profound circle and begin executing the following line of code.

Python language break articulation syntax:



Instance(Python 2.0+)

#!/usr/container/python # - *-coding: UTF-8 - *- for letter in 'Python': # First instance if letter == 'h': break print 'Current letter :', letter var = 10 # Second instance while var > 0: print 'Current variable esteem :', var var = var - 1 if var == 5: # Exit the circle when the variable var is equivalent to 5 break print "Good bye!"

The above model execution results´╝Ü

Current letter : P 

Current letter : y 

Current letter : t 

Current variable value : 10 

Current variable value : 9 

Current variable value : 8 

Current variable value : 7 

Current variable value : 6 

Good bye!

welookups is optimized for learning.© welookups 2018 -
All Right Reserved and you agree to have read and accepted our term and condition