Created
August 4, 2017 06:17
-
-
Save dmsurti/ef139fe84408cc10a403563563ed9496 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
#def is a keyword | |
# fizzbuzz_gen is the function name | |
# generates the fizzbuzz strings from 1 to n | |
def fizzbuzz_gen(n): | |
fizzbuzz_strings = [] | |
for num in range(1, n + 1): | |
print("Fizz buzz counting up to {}".format(num)) | |
if num % 3 == 0 and num % 5 == 0: | |
fizzbuzz_string.append("fizzbuzz") | |
elif num % 3 == 0: | |
fizzbuzz_string.append("fizz") | |
elif num % 5 == 0: | |
fizzbuzz_string.append("buzz") | |
else: | |
fizzbuzz_string.append(num) | |
return fizzbuzz_strings | |
fizzbuzz_100 = fizzbuzz_gen(100) | |
# fizzbuzz_100 will contain the 100 fizzbuzz strings |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment