Workout #9: First Last
Sep 22, 2021
Write a function, firstlast, that takes a sequence (string, list, or tuple) and returns the first and last elements of that sequence, in a two-element sequence of the same type. So firstlast(‘abc’) will return the string ac, while firstlast([1,2,3,4]) will return the list [1,4]
TRY IT YOURSELF
ANSWER
https://colab.research.google.com/drive/1ZuuPTbMvMjTp6swAKEsA5iX_bhPCW3L8?usp=sharing