Skip to content

Instantly share code, notes, and snippets.

@quandyfactory
Created April 28, 2010 18:46
Show Gist options
  • Save quandyfactory/382532 to your computer and use it in GitHub Desktop.
Save quandyfactory/382532 to your computer and use it in GitHub Desktop.
fizzbuzz solution in 5 lines of code (plus 1 line docstring).
def fizzbuzz(start=1, end=100, fizzval=3, buzzval=5):
"""Implements Reginald Braithwaite's FizzBuzz text."""
for i in range(start, end+1):
fizz = 'Fizz' if i % fizzval == 0 else ''
buzz = 'Buzz' if i % buzzval == 0 else ''
print i if fizz+buzz == '' else fizz+buzz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment