Last active
August 29, 2015 14:14
-
-
Save s3itz/584ba7d68f0621696176 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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