append list method only takes one argument. So, if you have a list
items, a call like
list.append(*items) only works if
items has a single
element in it. If there is more than one element in
items, this code will crash.
list.extend(items) instead of
list.append(*items), as the
former is more readable and will not crash when
items contains multiple elements.
trees = ['Mango', 'Cedar'] favorite_tree = ['Oak'] trees.append(*favorite_tree) # `append` is error-prone.
trees = ['Mango', 'Cedar'] favorite_tree = ['Oak'] trees.extend(favorite_tree) # Prefer `extend`.