Skip to content

Instantly share code, notes, and snippets.

@jasonsperske
Created July 19, 2012 16:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonsperske/3145186 to your computer and use it in GitHub Desktop.
Save jasonsperske/3145186 to your computer and use it in GitHub Desktop.
Fizz/Buzz in Python
# My First Python program
# Based on this spec: http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html
def fbFilter(n): return n % 5 == 0 or n % 3 == 0
def fbPrinter(n):
if n % 15 == 0:
return 'FizzBuzz'
elif n % 5 == 0:
return 'Buzz'
elif n % 3 == 0:
return 'Fizz'
map(fbPrinter, filter(fbFilter, range(1, 100)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment