Home »
Python
list() function with example in Python
Python list() function: Here, we are going to learn about the list() function in Python with example.
Submitted by IncludeHelp, on April 06, 2019
Python list() function
list() function is a library function, it is used to create a list, it accepts multiple elements enclosed within brackets (because list() takes only one argument. Thus, the set of elements within brackets is considered as a single argument).
Syntax:
list((elements))
Parameter(s): elements – list of the elements.
Return value: list – it returns a list of given elements.
Example:
Input:
students = list(("Amit shukla", "prem", "Radib", "Abhi"))
Output:
students: ['Amit shukla', 'prem', 'Radib', 'Abhi']
Python code to create a list using list() function
# python code to demonstrate example of
# list() method
# creating list
students = list(("Amit shukla", "prem", "Radib", "Abhi"))
# printing type of list() function
print("type of list() function: ", type(students))
# printing list...
print("students: ", students)
Output
type of list() function: <class 'list'>
students: ['Amit shukla', 'prem', 'Radib', 'Abhi']
ADVERTISEMENT
ADVERTISEMENT