Created
November 30, 2010 00:10
-
-
Save rlotun/720888 to your computer and use it in GitHub Desktop.
Fizzbuzz in Python-land
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
#!/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