Created
October 26, 2018 22:27
-
-
Save OzuYatamutsu/86175e63284d8508d51e15ea6d281a40 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 fizzbuzz(n: int) -> None: | |
""" | |
Prints out a series of numbers, 1 to n (inclusive), following these rules: | |
If n is divisible by 2, print 'fizz' | |
If n is divisible by 3, print 'buzz' | |
If both apply, print 'fizzbuzz' | |
If neither, print the number. | |
""" | |
for i in range(1, n+1): | |
print( | |
f"{'fizz' if (n % 2) else ''}" | |
f"{'buzz' if (n % 3) else ''}" | |
f"{n if not ((n % 2) or (n % 3)) else ''}" | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment