Skip to content

Instantly share code, notes, and snippets.

@s3itz
Last active August 29, 2015 14:14
Show Gist options
  • Save s3itz/584ba7d68f0621696176 to your computer and use it in GitHub Desktop.
Save s3itz/584ba7d68f0621696176 to your computer and use it in GitHub Desktop.
import sys
n = None
try:
n = int(sys.argv[1])
except (ValueError, IndexError) as e:
pass # Ignore error here
if (len(sys.argv) == 1) or (n is None):
good_to_go = False
while not good_to_go:
input = raw_input("Enter a number: ")
try:
n = int(input)
except ValueError:
print "Invalid input."
continue
good_to_go = True
for n in range(1, n+1):
s = ''
if n % 3 == 0:
s += 'Fizz'
if n % 5 == 0:
s += 'Buzz'
if s:
print s
else:
print n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment