...

/

Solution: Improving Code Readability

Solution: Improving Code Readability

Review the solution to the challenge.

We'll cover the following...

Solution

The complete code is provided below:

Press + to interact
def fizzBuzz(n):
"""
This function takes a number n as input and prints "Fizz" for multiples of 3, "Buzz" for multiples of 5,
and "FizzBuzz" for multiples of both 3 and 5, otherwise, it prints the number.
"""
if n % 3 == 0 and n % 5 == 0:
print("FizzBuzz")
elif n % 3 == 0:
print("Fizz")
elif n % 5 == 0:
print("Buzz")
else:
print(n)
fizzBuzz(15)
fizzBuzz(18)
fizzBuzz(25)
fizzBuzz(4)

Explanation

  • On
...