Because you haven't return anything.
If code is like this:
def lucky_number(name):
number = int(len(name) * 9)
pr = "Hello " + name + ". Your lucky number is " + str(number)
print(str(pr))
return "OK"
print(lucky_number("Kay"))
print(lucky_number("Cameron"))
Output:
Hello Kay. Your lucky number is 27
OK
Hello Cameron. Your lucky number is 63
OK
Calling the function in print(), prints the output of the function, in this case OK. But the string that you wanted to print is printed by the function itself, not because of the print that is calling the function.
So code like this:
def lucky_number(name):
number = int(len(name) * 9)
pr = "Hello " + name + ". Your lucky number is " + str(number)
print(str(pr))
lucky_number("Kay")
lucky_number("Cameron")
Output:
Hello Kay. Your lucky number is 27
Hello Cameron. Your lucky number is 63