Insert
Revision as of 17:42, 16 March 2020 by 71.226.33.30 (talk) (Created page with "<c>insert</c> inserts a new element into a string or list. See also: remove === Arguments === {| class="wikitable" |- ! Parameter Name !! Default Value !! Meaning |- |...")
insert
inserts a new element into a string or list.
See also: remove
Arguments
Parameter Name | Default Value | Meaning |
---|---|---|
self | string or list | sequence to insert into |
index | number | position at which to insert the new item |
value | any | element to insert at the specified index |
Usage Notes
In the case of a list, the list is both modified in place and returned. Strings are immutable, so in that case the original string is unchanged, but a new string is returned with the value inserted.
Example
"Hello".insert(2, 42) // returns "He42llo"