22.6k views
4 votes
The function below takes one parameter: a list (given_list). Complete the function to create a new list containing the first three elements of the given list and return it. You can assume that the provided list always has at least three elements. This can be implemented simply by creating (and returning) a list whose elements are the values at the zero'th, first and second indices of the given list. Alternatively, you can use the list slicing notation.

User Yussan
by
6.4k points

1 Answer

0 votes

Answer:

def make_list(given_list):

lst = []

lst.append(given_list[0])

lst.append(given_list[1])

lst.append(given_list[2])

return lst

Step-by-step explanation:

Create a function called make_list that takes one parameter, given_list

Initialize an empty list to hold the first three elements in the given_list

Put the first three elements to the lst using append function

Return the lst

User Chris Dale
by
5.5k points