list.append() adds exactly one object to the end of an existing list. It changes the list in place and is useful when a program builds a sequence incrementally. section 3.3.1 section 3.3.2
Append and verify
>>> items = [] >>> items.append('sammiches') >>> assert len(items) == 1 >>> items ['sammiches'] The call produces no displayed value, so inspect the list or assert its expected length. section 3.3.1
Choose append() when the intended result is one new element:
- items.append(['chips', 'ice cream']) adds the entire list as one nested element, producing ['sammiches', ['chips', 'ice cream']]. section 3.3.2
- items.extend(['chips', 'ice cream']) adds both strings separately; passing two arguments to append() raises TypeError. section 3.3.2
- Use += as an alternative spelling when adding one chosen value to a list during a loop. section 12.3.3
- For verse lines, append() incorrectly stores a reversed iterator or list as one element; extend() is needed to add each line separately. section 13.3.1
>>> items.append('sammiches')
Run the minimal REPL operation, then inspect the list with b6 or verify it with b5. section 3.3.1

