list ()

The syntax for the list () method is given as follows:

list(tuple)

The list function converts the sequence into a list. Let's see the following example:

>>> tup1 = ("a","b","c")

>>> list (tup1)

['a', 'b', 'c']

>>> name = "mohit raj"

>>> list1(name)

>>> list(name)

['m', 'o', 'h', 'i', 't', ' ', 'r', 'a', 'j']

>>>

You can see that the tuple, tup1, and string name have been converted into a list.

Python offers you a function to sort the list, called sorted ().

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.197.95