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.
Wednesday, May 11, 2016
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.