Skip to content

Instantly share code, notes, and snippets.

@ahawker
Created December 15, 2012 01:11
Show Gist options
  • Save ahawker/4290196 to your computer and use it in GitHub Desktop.
Save ahawker/4290196 to your computer and use it in GitHub Desktop.
FizzBuzz in Python (2.7).
#!/usr/bin/env python
def main():
for x in xrange(1, 101):
div3 = x % 3 == 0
div5 = x % 5 == 0
if div3 and div5:
print 'FizzBuzz'
elif div3:
print 'Fizz'
elif div5:
print 'Buzz'
else:
print x
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment