Search code examples
pythonif-statementreturnreturn-valuefizzbuzz

return statement not responding what should i do


def fizz_buzz(num):
    if num % 3 == 0 and num % 5 == 0:
        return "Fizz Buzz"
    elif num % 3 == 0:
        return "Fizz"
    elif num % 5 == 0:
        return "Buzz"
    return num

fizz_buzz(15)
  1. I don't know why my return statement is working.
  2. Conditions are aligned properly
  3. I referred this code:

enter image description here

  1. He used input instead I used num
  2. I don't want to use input shown in reference code

Solution

  • The code runs fine. If you're wondering why you're not getting an output, you have to print the value the function returns.

    print(fizz_buzz(15))