Created
July 20, 2017 19:59
-
-
Save mudspringhiker/03da984362a7ec1a7cfaf1fc0d4f6b06 to your computer and use it in GitHub Desktop.
First Thinkful project: 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 | |
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