Last active
December 11, 2015 13:09
-
-
Save softarn/4605843 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in [1,2,3]: | |
print i | |
else: | |
print 4 | |
#Will print 1 2 3 4 | |
#But if you break the loop... | |
for i in [1,2,3]: | |
print i | |
break | |
else: | |
print 4 | |
#This will only print 1 | |
#Usage example | |
user_input = int(raw_input()); | |
for i in [1,2,3,4]: | |
if i == user_input: | |
print "found" | |
break | |
else: | |
print "not found" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment