Created
March 18, 2015 17:16
-
-
Save nchlswtsn/4c9bc8375a139f998c22 to your computer and use it in GitHub Desktop.
FizzBuzz
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 | |
length = len(sys.argv) | |
script = sys.argv[0] | |
if len(sys.argv) == 1: | |
print "You supplied %d arguments at run time exclusively consisting of %s" % (length, script) | |
user_n = int(raw_input("Please enter a max limit: ")) | |
else: | |
user_n = int(sys.argv[1]) | |
print "You supplied {} arguments at run time".format(len(sys.argv)) | |
fizzbuzz = 0 | |
count = True | |
while fizzbuzz <= user_n: | |
if fizzbuzz % 3 == 0 and fizzbuzz % 5 == 0: | |
print "Fizz Buzz" | |
fizzbuzz += 1 | |
elif fizzbuzz % 3 == 0: | |
print "Fizz" | |
fizzbuzz += 1 | |
elif fizzbuzz % 5 == 0: | |
print "Buzz" | |
fizzbuzz += 1 | |
else: | |
print fizzbuzz | |
fizzbuzz += 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment