diff --git a/challenges/fizzbuzz/solutions/python/function/README.md b/challenges/fizzbuzz/solutions/python/function/README.md new file mode 100644 index 0000000..838aeb9 --- /dev/null +++ b/challenges/fizzbuzz/solutions/python/function/README.md @@ -0,0 +1,3 @@ +# fizzbuzz/python/function + +Created by [@Divlo](https://github.com/Divlo) on 30 June 2021. diff --git a/challenges/fizzbuzz/solutions/python/function/solution.py b/challenges/fizzbuzz/solutions/python/function/solution.py new file mode 100644 index 0000000..8bbdaa1 --- /dev/null +++ b/challenges/fizzbuzz/solutions/python/function/solution.py @@ -0,0 +1,23 @@ +from typing import List +import sys + +input_values: List[str] = [] +for value in sys.stdin: + input_values.append(value.rstrip('\n')) + + +def fizzbuzz(length: int) -> None: + for number in range(1, length + 1, 1): + is_divisible_by_3 = number % 3 == 0 + is_divisible_by_5 = number % 5 == 0 + if is_divisible_by_3 and is_divisible_by_5: + print("FizzBuzz") + elif is_divisible_by_3: + print("Fizz") + elif is_divisible_by_5: + print("Buzz") + else: + print(number) + + +fizzbuzz(int(input_values[0]))