| removes all items from *s* (same | (5) | | | as "del s[:]") | | +--------------------------------+----------------------------------+-----------------------+ | "s.copy()" | creates a shallow copy of *s* | (5) | | | (same as "s[:]") | | +--------------------------------+----------------------------------+-----------------------+ | "s.extend(t)" or "s += t" | extends *s* with the contents of | | | | *t* (for the most part the same | | | | as "s[len(s):len(s)] = t") | | +--------------------------------+----------------------------------+-----------------------+ | "s *= n" | updates *s* with its contents | (6) | | | repeated *n* times | | +--------------------------------+----------------------------------+-----------------------+ | "s.insert(i, x)" | inserts *x* into *s* at the | | | | index given by *i* (same as | | | | "s[i:i] = [x]") | | +--------------------------------+----------------------------------+-----------------------+ | "s.pop()" or "s.pop(i)" | retrieves the item at *i* and | (2) | | | also removes it from *s* | | +--------------------------------+----------------------------------+-----------------------+ | "s.remove(x)" | remove the first item from *s* | (3) | | | where "s[i]" is equal to *x* | | +--------------------------------+----------------------------------+-----------------------+ | "s.reverse()" | reverses the items of *s* in | (4) | | | place | | +--------------------------------+----------------------------------+-----------------------+ Notes: 1. *t* must have the same length as the slice it is replacing. 2. The optional argument *i* defaults to "-1", so that by default the last item is removed and returned. 3. "remove()" raises "ValueError" when *x* is not found in *s*. 4. The "reverse()" method modifies the sequence in place for economy of space when reversing a large sequence. To remind users that it operates by side effect, it does not return the reversed sequence. 5. "clear()" and "copy()" are included for consistency with the interfaces of mutable containers that don’t support slicing operations (such as "dict" and "set"). "copy()" is not part of the "collections.abc.MutableSequence" ABC, but most concrete mutable sequence classes provide it. New in version 3.3: "clear()" and "copy()" methods. 6. The value *n* is an integer, or an object implementing "__index__()". Zero and negative values of *n* clear the sequence. Items in the sequence are not copied; they are referenced multiple times, as explained for "s * n" under Common Sequence Operations. aM