← Back

Home › Output practice › append() gives you None

Predict the output: append() gives you None

🔮 Predict the outputTopic: listsDifficulty: easyNo login needed

The snippet

One Python convention decides this question: a method that mutates a container in place returns None on purpose, so you can never mistake "I changed it" for "I got a new one".

words = ["cat"]
extra = words.append("dog")
print(extra)
print(words)

Your prediction

Type exactly what this program prints — one line per print() call:

The output

None
['cat', 'dog']

Verified against CPython 3.11 in this repo's build

Line-by-line explanation

  1. words = ["cat"]
    A one-element list.
  2. extra = words.append("dog")
    append inserts into words and returns nothing — in Python, "nothing" is the object None.
  3. print(extra)
    None — the return value, not the list. This is the line that breaks real code: words = words.append(...) replaces the list with None.
  4. print(words)
    The mutation did happen, so the list itself reads ['cat', 'dog'].

The rule you can reuse

In-place list methods return None: append, extend, insert, sort, reverse, clear. Functions and methods that build a new object return it: sorted(), list.copy(), +, reversed().

Why most predictions break here

Writing the appended list on the first line. print(extra) never shows the list — and print(words.append(x)) shows None even though the append worked.

Quick fire

Same rule, two more shapes. Predict first, then open.

Predict this too
nums = [3, 1, 2]
print(nums.sort())
print(nums)

Output
None
[1, 2, 3]

sort() orders in place and returns None → None then [1, 2, 3].

Predict this too
a = [1]
b = a + [2]
print(a)
print(b)

Output
[1]
[1, 2]

+ builds a new list instead of mutating, so a stays [1] and b is [1, 2].

Share your result

Challenge a friend — the link contains the question, never the answer:

Copied ✓

Keep practising this rule

More output questions → All interactive problems

Questions this page answers

Is returning None just a style choice?

It is a deliberate design rule for in-place operations, shared with the standard library (random.shuffle, list.sort). Guido van Rossum has said he wishes he had not made it uniform, because beginners trip on it — but the guarantee is that you never silently get a copy.

How do I get a sorted new list without mutating?

ranking = sorted(scores) — it returns a new list, so the original keeps its order.