What is the syntax to terminate a loop?

break
#example
langs=['java','racket','python','C++']
for language in langs:
    print(language)
    if language == 'python':
        print('Found Python in this list!')
        break

#output
java
racket
python
Found Python in this list!

 

 

 

Advertisements