Last active
July 23, 2018 07:13
-
-
Save mGalarnyk/cf11c966c2e7b655f3e776bff13baf8a to your computer and use it in GitHub Desktop.
FizzBuzz Python Solution for the blog post: https://medium.com/@GalarnykMichael/python-basics-8-fizzbuzz-441e97c6c767
This file contains hidden or 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
""" | |
Write a program that prints the numbers from 1 to 20. But for multiples of three, print 'Fizz' | |
instead of the number and for the multiples of five print 'Buzz'. | |
For numbers which are multiples of both three and five print 'FizzBuzz'. | |
""" | |
for num in range(1,21): | |
string = "" | |
if num % 3 == 0: | |
string = string + "Fizz" | |
if num % 5 == 0: | |
string = string + "Buzz" | |
if num % 5 != 0 and num % 3 != 0: | |
string = string + str(num) | |
print(string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment