Skip to content

Instantly share code, notes, and snippets.

@swinton
Created November 30, 2012 15:02
Show Gist options
  • Select an option

  • Save swinton/4176270 to your computer and use it in GitHub Desktop.

Select an option

Save swinton/4176270 to your computer and use it in GitHub Desktop.
fizzbuzz.py
#!/usr/bin/env python
def fizzbuzz(start=1, stop=100):
for i in xrange(start, stop + 1):
if i % 3 == 0 and i % 5 == 0:
yield "FizzBuzz"
elif i % 3 == 0:
yield "Fizz"
elif i % 5 == 0:
yield "Buzz"
else:
yield i
if __name__ == "__main__":
for i in fizzbuzz(1, 100):
print i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment