Skip to content

Instantly share code, notes, and snippets.

@mudspringhiker
Created July 20, 2017 19:59
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 mudspringhiker/03da984362a7ec1a7cfaf1fc0d4f6b06 to your computer and use it in GitHub Desktop.
Save mudspringhiker/03da984362a7ec1a7cfaf1fc0d4f6b06 to your computer and use it in GitHub Desktop.
First Thinkful project: Fizzbuzz
import sys
def main():
header()
try:
limit = int(sys.argv[1])
except:
limit = int(input("Up to what number do you want to count to? "))
for i in range(1, limit+1):
fizzbuzz(i)
print("Goodbye!")
def header():
print("------------------------")
print(" FIZZBUZZ")
print("------------------------")
print()
def fizzbuzz(n):
if n % 5 == 0 and n % 3 == 0:
print("FizzBuzz")
elif n % 3 == 0:
print("Fizz")
elif n % 5 == 0:
print("Buzz")
else:
print(n)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment