What does the list() function do in Python?

前端 未结 6 1455
暖寄归人
暖寄归人 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:49

    aTuple = (123, 'xyz', 'zara', 'abc');
    aList = list(aTuple)
    
    print "List elements : ", aList
    

    When we run above program, it produces following result:

    List elements :  [123, 'xyz', 'zara', 'abc']
    

    It is another way to create a list in python. How convenient!

提交回复
热议问题