I have been posed the following question:
Make a new function named first_and_last_4. It'll accept a single iterable but, this time, it'll return the first four and last four items as a single value.
Here is my code:
def first_and_last_4(x):
first_4 = x[:4]
last_4 = x[-4:]
return (first_4.extend(last_4))
I have also tried to simplify this:
def first_and_last_4(x):
return x[:4] + x[-4:]
Error:
Bummer: Couldn't find
first_4
Can you help?