Skip to content

Instantly share code, notes, and snippets.

@rlotun

rlotun/fizzbuzz.py

Created Nov 30, 2010
Embed
What would you like to do?
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
You can’t perform that action at this time.