print("hello", print("world"))
Asked
Active
Viewed 64 times
0
-
3Why, did you print in print ? – Herlock Oct 11 '22 at 19:04
-
3Because you are printing the return value of `print()`. – takendarkk Oct 11 '22 at 19:05
-
1Does this answer your question? [Why is "None" printed after my function's output?](https://stackoverflow.com/questions/7053652/why-is-none-printed-after-my-functions-output) – buran Oct 11 '22 at 19:07
-
Are you not also curious why `world` is output before `hello`? – buran Oct 11 '22 at 19:08
2 Answers
-1
It looks like you are trying to do
print("hello", "world")
Expressions (like print(something)
) are evaluated from the inside-out. That lets you do stuff like
print(1 + 2)
# prints 3
The return value of print
is None
. So when you run print("hello", print("world"))
, first "world"
is printed, and then you essentially have print("hello", None)
.

Axel Jacobsen
- 148
- 10
-1
Because print itself does not return anything, i.e. it returns None
.
Your nested print statements are evaluated from the inside out, that is why world
prints first and then hello
+ the return value of print
= None

bimtauer
- 29
- 5