Skip to content

Instantly share code, notes, and snippets.

@matthewspear
Last active February 15, 2016 22:07
Show Gist options
  • Save matthewspear/bf3ef65a0ba301880096 to your computer and use it in GitHub Desktop.
Save matthewspear/bf3ef65a0ba301880096 to your computer and use it in GitHub Desktop.
Functional FizzBuzz Generator in Python
# Functional FizzBuzz Generator in Python
def fizz_buzz(num):
if num % 3 == 0 and num % 5 == 0:
return 'FizzBuzz'
elif num % 3 == 0:
return 'Fizz'
elif num % 5 == 0:
return 'Buzz'
else:
return str(num)
print ', '.join(map(fizz_buzz, range(1,101)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment