Let's break down this code step by step: ```python print(None, print(5)) ``` ### **Innermost...

September 15, 2025 at 03:18 AM

print(None, print(5))

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 value 5 to the console as a side effect and returns None. Why? Because the print() function in Python does not produce a return value—it returns None.

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. The print() 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) outputs 5 and returns None.
  • Then print(None, None) prints None 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