In one book I found thatprint(print("any text"))
returns the size of text inside the function. i.e. 8 Here
But in another book I found out that it returns None
.
So which answer is true? Or whether the 2nd answer is just an updated answer...?
print()
function doesn't return anything (so it's None
). When you're printing the output of a function which returns None
, sure the output is None
. So the 2nd book is correct.
>>> print(print())
None
If you want get the length of a string, you should use len()
function:
>>> print(len("any text"))
8