My fizzbuzz code keeps giving me none as an output i dont know why please help.
Here is my code:
def FizzBuzz(num):
for num in range (1,50):
string = ""
if num % 3 == 0:
string = string + "Fizz"
if num % 5 == 0:
string = string + "Buzz"
if num % 5 != 0 and num % 3 != 0:
string = string + str(num)
print (string)
print FizzBuzz(raw_input())
You have not used proper intendation in the code.
print FizzBuzz(raw_input())
This statement doesn't print anything because the FizzBuzz function is not returning any value to the function call. (None is taken as return value)
def FizzBuzz(num):
for num in range (1,50):
string = ""
if num % 3 == 0:
string = string + "Fizz"
if num % 5 == 0:
string = string + "Buzz"
if num % 5 != 0 and num % 3 != 0:
string = string + str(num)
print (string)
FizzBuzz(raw_input()) # function call (no need to use print statement as nothing is returned```