Skip to content

Instantly share code, notes, and snippets.

@thomasgassmann
Last active June 23, 2018 22:02
Show Gist options
  • Select an option

  • Save thomasgassmann/7b9bdd43b133c4f1067c9396dbb96668 to your computer and use it in GitHub Desktop.

Select an option

Save thomasgassmann/7b9bdd43b133c4f1067c9396dbb96668 to your computer and use it in GitHub Desktop.
FizzBuzz in Python
rules = {
3: 'Fizz',
5: 'Buzz'
}
for i in range(1, 1000):
output = [rules[key] if i % key == 0 else '' for key in rules]
output = ''.join(output)
print(output if output != '' else i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment