88.7k views
5 votes
g 'write a function that takes as input a list and outs a new list containing all elements from the input

1 Answer

5 votes

Answer:

def mylist(*args):

return args

new_list = mylist(2,3,4,5)

Step-by-step explanation:

The simple python code above defines a function called mylist that receives multiple length of element as a list and returns the list a new list. The "*args" allows the function to receive any number of item and converts them to a list that is returned in the next statement.

The can also be achieved by simply assigning a squared bracket enclosed list to the variable or with the list() constructor.

User CPPL
by
9.0k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.