Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Fizz Buzz by BukiBuki
def checkio(num: int) -> str:
result = []
if num % 3 == 0:
result.append('Fizz')
if num % 5 == 0:
result.append('Buzz')
if not result:
return str(num)
return " ".join(result)
if __name__ == '__main__':
print("Example:")
print(checkio(15))
print(checkio(6))
print(checkio(10))
print(checkio(7))
# These "asserts" are used for self-checking
assert checkio(15) == "Fizz Buzz"
assert checkio(6) == "Fizz"
assert checkio(10) == "Buzz"
assert checkio(7) == "7"
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 8, 2023