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']





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL







Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.