Skip to content

Instantly share code, notes, and snippets.

@jmcabandara
Forked from jaysonrowe/FizzBuzz.py
Created July 23, 2018 07:12
Show Gist options
  • Save jmcabandara/05859bea26a953a2e289a6fc6f5a2d5c to your computer and use it in GitHub Desktop.
Save jmcabandara/05859bea26a953a2e289a6fc6f5a2d5c to your computer and use it in GitHub Desktop.
FizzBuzz Python Solution
def fizzbuzz(n):
if n % 3 == 0 and n % 5 == 0:
return 'FizzBuzz'
elif n % 3 == 0:
return 'Fizz'
elif n % 5 == 0:
return 'Buzz'
else:
return str(n)
print "\n".join(fizzbuzz(n) for n in xrange(1, 21))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment