Skip to content

Instantly share code, notes, and snippets.

@rlotun
Created November 30, 2010 00:10
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 rlotun/720888 to your computer and use it in GitHub Desktop.
Save rlotun/720888 to your computer and use it in GitHub Desktop.
Fizzbuzz in Python-land
#!/usr/bin/python
for i in xrange(1, 101):
print ''.join(['fizz' if i % 3 == 0 else '', 'buzz' if i % 5 == 0 else '']) or i
# or simply:
print '\n'.join([''.join(['fizz' if i % 3 == 0 else '', 'buzz' if i % 5 == 0 else '']) or str(i) for i in xrange(1, 101)])
# command-line one liner foo:
python -c "print '\n'.join([''.join(['fizz' if i % 3 == 0 else '', 'buzz' if i % 5 == 0 else '']) or str(i) for i in xrange(1, 101)])"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment