insert()
insert()
takes in a string, and index, and a character, and inserts the character into the string at the given index.
insert(str, index, value)
str
: The string where thatvalue
will be inserted into
index
: The index ofstr
wherevalue
will be inserted
value
: The character that is being inserted intostr
A new string that has been modified.
insert('laughter', 0, 's')
output:
'slaughter'