Python Tutorial

Python List With Examples

What are Lists in Python?

You can store multiple things in a single variable by making use of lists. Lists in Python are one of four built-in Python data structures for storing collections of data; the other three are Tuple, Set, and Dictionary, all of which have various properties and applications. Square brackets are used to make lists.

Knowing Size of a List in Python

To evaluate the length of lists in Python, you can use the len() function.

Example:

thislist = ["pear", "melon", "orange"]

print(len(thislist))

Output

3

How to Create a New Python List?

You can also create a new list in Python using the list() constructor function.

Example

thislist = list(("wscube", "python", "code"))

print(thislist)
Output:
("wscube", "python", "code")
Did you find this article helpful?