Python Python Collections Slices Slice Functions

Brian Wilkes
Brian Wilkes
1,507 Points

first_and_last_4 issue

"OK, this second one should be pretty similar to the first. 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."

i think i am doing what is being asked, at least my own workspace works. Can anyone see any reason they say its not correct?

thanks!

slices.py
def first_4(list1):
  first_4 = list1[0:4]
  print(first_4)

def first_and_last_4(list1):
  first = list1[0:4]
  last = len(list1)-4
  last_4 = list1[last:]
  first_and_last_4 = first + last_4
  print(first_and_last_4)

1 Answer

Brian Wilkes
Brian Wilkes
1,507 Points

Never mind I forgot to return the answer...