Skip to content

Instantly share code, notes, and snippets.

@punkrockpolly
Last active December 19, 2015 14:09
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 punkrockpolly/5967289 to your computer and use it in GitHub Desktop.
Save punkrockpolly/5967289 to your computer and use it in GitHub Desktop.
FizzBuzz: Write a program that prints out the numbers 1 to 100 (inclusive). If the number is divisible by 3, print Fizz instead of the number. If it's divisible by 5, print Buzz. If it's divisible by both 3 and 5, print FizzBuzz.
for x in range (1, 101):
output = ""
if x%3 == 0:
output += "Fizz"
if x%5 == 0:
output += "Buzz"
if output == "":
print x
else:
print output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment