Jul-31-2018, 03:50 PM
Hi, I am following a set of exercises, and I got stuck a bit on this one:
Write a function that returns the first and last elements of a list.
My code worked when the list was set, but when I use randomly created list, the command returns the whole list twice.
thurpe
Write a function that returns the first and last elements of a list.
My code worked when the list was set, but when I use randomly created list, the command returns the whole list twice.
import random def listing(): list = [random.sample(range(1,100),10)] return [list[0], list[-1]] print(listing())Can you please check?:)
thurpe