Skip to content

Instantly share code, notes, and snippets.

@tdesire
Created October 22, 2018 20:41
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 tdesire/0a24cecbcc474fdfc06d3ef49f785f6a to your computer and use it in GitHub Desktop.
Save tdesire/0a24cecbcc474fdfc06d3ef49f785f6a to your computer and use it in GitHub Desktop.
import sys
if len(sys.argv) == 2:
try:
n = int(sys.argv[1])
print("Fizz buzz counting up to {}".format(n))
while count <= n:
if count % 15 == 0:
print('Fizzbuzz')
elif count % 3 == 0:
print('Fizz')
elif count % 5 == 0:
print('Buzz')
else:
print(count)
count += 1
except ValueError:
print('You must enter a valid integer')
else:
try:
n = int(input("Enter a number to count to: "))
n
print("Fizz buzz counting up to {}".format(n))
while count <= n:
if count % 15 == 0:
print('Fizzbuzz')
elif count % 3 == 0:
print('Fizz')
elif count % 5 == 0:
print('Buzz')
else:
print(count)
count += 1
except ValueError:
print('You must enter a valid integer')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment