Skip to content

Instantly share code, notes, and snippets.

@softarn
Last active December 11, 2015 13:09
Show Gist options
  • Save softarn/4605843 to your computer and use it in GitHub Desktop.
Save softarn/4605843 to your computer and use it in GitHub Desktop.
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