Append and extend a list
Input
append_and_extend([1, 2], 3, [4, 5])
Output
[1, 2, 3, 4, 5]
First append 3 to [1, 2] -> [1, 2, 3], then extend with [4, 5] -> [1, 2, 3, 4, 5].
Full lesson preview
Learn how to add a single item to a list and then extend it with another iterable, returning the modified list.
Problem statement
Task
Examples
Input
append_and_extend([1, 2], 3, [4, 5])
Output
[1, 2, 3, 4, 5]
First append 3 to [1, 2] -> [1, 2, 3], then extend with [4, 5] -> [1, 2, 3, 4, 5].
Input format
Output format
Constraints
Samples
Input
append_and_extend([], 'a', [])
Output
['a']
Appending 'a' to an empty list and extending with an empty iterable results in ['a'].