Skip to content

Instantly share code, notes, and snippets.

@yon2004
Created April 4, 2018 15:38
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 yon2004/e55d85d6c9d597c379630940645cc968 to your computer and use it in GitHub Desktop.
Save yon2004/e55d85d6c9d597c379630940645cc968 to your computer and use it in GitHub Desktop.
#Fizz buzz is a group word game for children to teach them about division.
#Players take turns to count incrementally, replacing any number divisible by three with the word "fizz"
#and any number divisible by five with the word "buzz".
def FizzBuzz(fizz_num):
out = []
if fizz_num % 3 == 0:
out.append("Fizz")
if fizz_num % 5 == 0:
out.append("Buzz")
if out:
return "".join(out)
else:
return "{}".format(fizz_num)
for number in range(1, 101):
print(FizzBuzz(number))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment