Skip to content

Instantly share code, notes, and snippets.

@OzTamir
Last active August 29, 2015 13:56
Show Gist options
  • Save OzTamir/9267456 to your computer and use it in GitHub Desktop.
Save OzTamir/9267456 to your computer and use it in GitHub Desktop.
One line 'FizzBuzz' - Without a single if!
# 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