1 of 151 menu

The list function

The list function creates a new list from the original object. In the parameter, we specify the object from which we will make the list.

Syntax

list(the object from which we make a list)

Example

Let's use the list function to make a list from a string:

txt = 'abcdef' lst = list(txt) print(lst)

Result of code execution:

['a', 'b', 'c', 'd', 'e', 'f']

Example

Now let's make a list from a tuple:

tlp = ('ab', 1, 'cd', 2) lst = list(tlp) print(lst)

Result of code execution:

['ab', 1, 'cd', 2]

Example

Let's make a list of the many:

st = {1, 2, 3, 4} lst = list(st) print(lst)

Result of code execution:

[1, 2, 3, 4]

See also

  • function dict,
    which creates a dictionary
  • function str,
    which creates a string
  • function tuple,
    which creates a tuple
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline