append()

A list method that adds one item to the end of the list, changing the list in place.

In more detail

append returns None, so nums = nums.append(4) loses your list; just write nums.append(4). Building a list by starting with [] and appending in a loop is the list version of the accumulation pattern. + creates a new list instead.

Example

nums = []
nums.append(4)

Related terms

Taught in

References

Certification courses