Last active
August 29, 2015 13:56
-
-
Save OzTamir/9267456 to your computer and use it in GitHub Desktop.
One line 'FizzBuzz' - Without a single if!
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
# 3 - Fizz | |
# 5 - Buzz | |
# 15 - FizzBuzz | |
# With empty strings | |
a = ['Fizz' * (not (i % 3)) + 'Buzz' * (not (i % 5)) for i in xrange(100)] | |
# Without empty strings | |
b = filter(None, (['Fizz' * (not (i % 3)) + 'Buzz' * (not (i % 5)) for i in xrange(100)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment