Let's break down this code step by step: ```python print(None, print(5)) ``` ### **Innermost...
September 15, 2025 at 03:18 AM
Let's break down this code step by step:
print(None, print(5))
Innermost Function Calls Are Evaluated First
Python will evaluate the arguments to a function (in this case, the print
function) from the inside out, i.e., it will first evaluate print(5)
.
print(5)
: This prints the value5
to the console as a side effect and returnsNone
. Why? Because theprint()
function in Python does not produce a return value—it returnsNone
.
Outer print
Execution
After the inner function print(5)
is executed, its return value (None
) is passed as an argument to the outer print()
along with the explicit None
.
So, the outer print
receives two arguments: None
(the explicitly provided argument) and None
(the return value from print(5)
).
- This results in
print(None, None)
being executed. Theprint()
displays its arguments with a space separating them.
Output
The result of running the code will be:
5
None None
Why This Happens?
- The
print(5)
outputs5
and returnsNone
. - Then
print(None, None)
printsNone None
. - The two outputs appear consecutively, as
print()
automatically adds a newline after each call.
Generate your own explanations
Download our vscode extension
Read other generated explanations
Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node