Return value of print statement in Python
Question:
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…?
Answers:
In python return value of print is None. Maybe you are confusing it with C, where the "printf" function returns the number of characters printed.
At first innner print function is executed and the string in inner print function i.e, "any text" is printed.
After that it prints none
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…?
In python return value of print is None. Maybe you are confusing it with C, where the "printf" function returns the number of characters printed.
At first innner print function is executed and the string in inner print function i.e, "any text" is printed.
After that it prints none