Home >Backend Development >Python Tutorial >How to create an empty list in python

How to create an empty list in python

藏色散人
藏色散人Original
2019-07-02 13:25:4223683browse

How to create an empty list in python

Python List (List) is the most basic data structure in Python. Each element in the sequence is assigned a number - its position, or index, with the first index being 0, the second index being 1, and so on.

How to create an empty list in python?

Python creates an empty list:

Creation of an empty list:

l = list()

Or:

l = []

Creation and expression of elements in list

fruits = ['apple', 'banana', 'pear', 'grapes', 'pineapple', 'watermelon']
fruits[2] #从0开始数起,第三个元素
pear

Related recommendations: "Python Tutorial"

The above is the detailed content of How to create an empty list in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn