Replace a middle slice
Input
replace_slice([1,2,3,4,5], 1, 3, [9,9])
Output
[1, 9, 9, 4, 5]
Elements at indices 1 and 2 are replaced by [9,9].
Full lesson preview
Replace a slice of a list with the contents of another list, following Python slice semantics.
Problem statement
Task
Examples
Input
replace_slice([1,2,3,4,5], 1, 3, [9,9])
Output
[1, 9, 9, 4, 5]
Elements at indices 1 and 2 are replaced by [9,9].
Input format
Output format
Constraints
Samples
Input
replace_slice([1,2,3], None, None, [9])
Output
[9]
Replacing the whole list with [9].