Python Python Collections (2016, retired 2019) Slices Slice Functions

How to return first_and_last_4 items as a single value

How do i join the two slices?

slices.py
def first_4(item):
    return item[0:4]


def first_and_last_4(item):
    return item

1 Answer

You can concatenate the slices with the + operator: slice1 + slice2