Python List() function

Published February 16, 2022

Lists are used in Python to store multiple items in a single variable. Lists are one of the four built-in data types for holding data collections. To create a list object, you’ll need to use the list() function. The list() function generates a changeable and ordered list of items from the collection.

Let's have a look at the syntax for list().

Syntax
The list () function has the following simple syntax.

list(iterable)

where the iterable, is the iterator object or the collection that need to be stored in a list


Example

In this example we, are going to create a list of various programming languages

Programming_Languages = ('Python', 'PHP', 'JavaScript', 'R');
aList = list(Programming_Languages)
print("List of Programming Language : ", Programming_Languages)


Output
If you execute the above code, you will see the following

List of Programming Language :  ('Python', 'PHP', 'JavaScript', 'R')

 

Download Source code

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

262 Views