Method append
modifies the list in-place and the return value None
In your case, you are creating an array — [6] — on the fly, then discarding it. The variable b ends up with the return value of None.
Why?
This comply with the principle of Command–query separation devised by Bertrand Meyer.
It states that every method should either be a command that performs an action, or a query that returns data to the caller, but not both.
In your example:
u.append(6)
append
modified the state of []
, so it’s not a best practice to return a value compliance with the principle.
In theoretical terms, this establishes a measure of sanity, whereby one can reason about a program's state without simultaneously modifying that state.
CQS is well-suited to the object-oriented methodology such as python.