Skip to content

Instantly share code, notes, and snippets.

@dsc
Created January 25, 2013 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsc/4631211 to your computer and use it in GitHub Desktop.
Save dsc/4631211 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
print "While:",
n = range(3)
while n:
print n.pop(),
else:
print "else!",
print
print "While-Break:",
n = range(3)
while n:
print "(body)",
break
else:
print "else!",
print
print "While-False:",
while False:
print "(body)",
else:
print "else!",
print
print "For:",
for i in range(3):
print i,
else:
print "else!",
print
print "For-Break:",
for i in range(3):
print "(body)",
break
else:
print "else!",
print
print "For-[]:",
for i in []:
print i,
else:
print "else!",
print
While: 2 1 0 else!
While-Break: (body)
While-False: else!
For: 0 1 2 else!
For-Break: (body)
For-[]: else!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment