Why function list si not working with multiple arguments?


I want create a list by using function list() on numbers 2,3,4,5.
Looks like

lista = list(2,3,4,5)

Will create a
TypeError: list expected at most 1 argument, got 4

But if I write

lista = list((2,3,4,5))  lista reffers to a list now.

Then why function list() is not rappresented as list(()) ?

because the list() function accepts an iterable, like a tuple.

See the documentation:


1 Like

The list() function creates a list object. It takes an optional parameter; a sequence or an iterator object.

In your first example,

lista = list(2,3,4,5)

You are attempting t pass multiple parameters; 2, 3, 4, 5 this is why you are getting TypeError.
With you second example, you are passing an sequence object (e.g. a tuple). which converts the tuple to a list.