Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Divide by 3 and "Fizz" (with in-line if) solution in Clear category for Just Fizz! by MarHar
def checkio(num: int) -> str:
# return "Fizz" if the number is divisible by 3 (remainder of zero)
# otherwise return the number as a string
return "Fizz" if num % 3 == 0 else str(num)
print("Example:")
print(checkio(3))
# These "asserts" are used for self-checking
assert checkio(15) == "Fizz"
assert checkio(6) == "Fizz"
assert checkio(10) == "10"
assert checkio(7) == "7"
print("The mission is done! Click 'Check Solution' to earn rewards!")
June 9, 2023
Comments: