Skip to content

Instantly share code, notes, and snippets.

@mGalarnyk
Last active July 23, 2018 07:13
Show Gist options
  • Save mGalarnyk/cf11c966c2e7b655f3e776bff13baf8a to your computer and use it in GitHub Desktop.
Save mGalarnyk/cf11c966c2e7b655f3e776bff13baf8a to your computer and use it in GitHub Desktop.
"""
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