@saedx has identified and corrected your issue. Python returns None
by default and that is what you see printed after the function returns.
You could implement your hello
function to be a bit more consistent in how it displays the strings. At present the first n-1 are printed in the body of the function but the caller is left to print the final one.
Here the function prints all n of the strings.
def hello(n):
print('hello')
if n > 1:
hello(n-1)
hello(5)
In this case you just call the function. You don't print what it returns.
The other way would be to have the caller print all n of the strings.
def hello(n):
yield 'hello'
if n > 1:
yield from hello(n-1)
Which is then called like
print('\n'.join(hello(5)))
Also note that both these examples remove the duplication of the string being printed. Its worth noting that if you passed in a number less than 1 you'd be in trouble, as it would recurse infinitely. So we could throw an exception in that case.