kata/fizzbuzz/fizzbuzz.py

22 lines
408 B
Python
Raw Normal View History

2019-11-30 11:36:58 +01:00
#! /usr/bin/env python
def fizzbuzz(max: int = 100) -> None:
words = {
3: "fizz",
5: "buzz",
}
2019-11-30 11:36:58 +01:00
for i in range(1, max + 1):
out = []
for div, word in words.items():
if i % div == 0:
out.append(word)
if len(out) > 0:
print("".join(out))
else:
print(i)
2019-11-30 11:36:58 +01:00
if __name__ == "__main__":
fizzbuzz()