What does the list() function do in Python?

前端 未结 6 1593
暖寄归人
暖寄归人 2020-12-19 11:14

I know that the list() constructor creates a new list but what exactly are its characteristics?

  1. What happens when you call list((1,2,3,4,

6条回答
  •  青春惊慌失措
    2020-12-19 11:57

    Yes it is true.

    Its very simple. list() takes an iterable object as input and adds its elements to a newly created list. Elements can be anything. It can also be an another list or an iterable object, and it will be added to the new list as it is.

    i.e no nested processing will happen.

提交回复
热议问题