diff --git a/fizzbuzz.py b/fizzbuzz.py new file mode 100644 index 0000000..da6a9bd --- /dev/null +++ b/fizzbuzz.py @@ -0,0 +1,9 @@ +def fb(N): + res = "" + if N % 3 == 0: + res += "Fizz" + if N % 5 == 0: + res += "Buzz" + if len(res) == 0: + res = str(N) + return res diff --git a/test_FizzBuzz.py b/test_FizzBuzz.py new file mode 100644 index 0000000..814cea2 --- /dev/null +++ b/test_FizzBuzz.py @@ -0,0 +1,9 @@ +from fizzbuzz import fb + +inputs = [1, 3, 5, 15] +results = ["1", "Fizz", "Buzz", "FizzBuzz"] + + +def test_fb(): + for i in range(len(inputs)): + assert fb(inputs[i]) == results[i]