Last active
February 15, 2016 22:07
-
-
Save matthewspear/bf3ef65a0ba301880096 to your computer and use it in GitHub Desktop.
Functional FizzBuzz Generator in Python
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
# 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