In python, like in several other languages, break and continue statements exist to control execution flow. But when it comes to else, it is something new :
for item in itemList:
if item == 'DeveloperLogBook':
print 'Item found'
break
else:
print 'Item not found !'
On the example above, else applies to for loop if it terminates "through exhaustion of the list".
Note: With a while loop, else applies if the condition assertion of while is false.
Showing posts with label else. Show all posts
Showing posts with label else. Show all posts
Wednesday, May 11, 2016
Subscribe to:
Posts (Atom)