Skip to content

Instantly share code, notes, and snippets.

@rm17tink
Forked from jaysonrowe/FizzBuzz.py
Created November 11, 2021 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rm17tink/29e87e7992d3f06f10152c7174f047fd to your computer and use it in GitHub Desktop.
Save rm17tink/29e87e7992d3f06f10152c7174f047fd 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