Created
September 29, 2020 09:02
-
-
Save ndricca/296f9e6e481ab144ac67b11bd90050cb 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
MULTIPLES_DICT = { | |
3: 'Fizz', | |
5: 'Buzz', | |
7: 'Wolf', | |
} | |
def _is_by_num(num: int, multiple: int) -> bool: | |
return num % multiple == 0 | |
def _get_string_by_multiple(mult: int ) -> str: | |
return MULTIPLES_DICT.get(mult) | |
def fizz_buzz(num: int) -> str: | |
res = '' | |
for mult in MULTIPLES_DICT.keys(): | |
if _is_by_num(num, mult): | |
res += _get_string_by_multiple(mult) | |
return res if res != '' else str(num) | |
if __name__ == '__main__': | |
for i in range(100,110): | |
print((i,fizz_buzz(i))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment