If you assign items from another list, your whole line might look something like this:
The resulting list now looks like this:
The following example manipulates a list of words by using slice assignment:
>>> L = ['spam', 'eggs', 'ham', 'green eggs']
>>> L[:2] = ("don't", "want") >>> L
>>> L[2:] = ("green eggs", "and", "ham") >>> L
["don't", 'want', 'green eggs', 'and', 'ham']
Was this article helpful?