it should iterate till that number and follow condition and I don't want it should return None for 16th iteration

Viewed 17

** it should iterate until that number and follow the condition, and I don't want it to return None for the 16th iteration**
def fizzbizz(number): for i in range(1,number + 1): if i % 3 == 0 and i % 5 == 0: print("fizzBuzz")

      elif i % 3 == 0 and i % 5 != 0:
          print("fizz")

      elif i % 3 != 0 and i % 5 == 0:
         print("Buzz")

      else:
         print(str(i))

if __name__ == '__main__':
print(fizzbizz(15))

output is : 
1
2
fizz
4
Buzz
fizz
7
8
fizz
Buzz
11
fizz
13
14
fizzBuzz
None
1 Answers

You are printing the function instead of just calling it, and the function returns None

Related