Home >Backend Development >Python Tutorial >Is python list ordered?

Is python list ordered?

(*-*)浩
(*-*)浩Original
2019-08-01 10:29:166547browse

List, one of Python's basic data types, is very powerful in Python. List can contain different types of data objects, and it is an ordered collection.

Is python list ordered?

All standard operation methods that can be used for sequences can also be used for lists, such as slicing, indexing, etc. Python’s list is Variable data type, which supports append, insert, modify, delete del and other operations. (Recommended learning: Python video tutorial)

You can understand the list in python as a sequence of arbitrary objects, just put the required parameter values ​​​​in square brackets [ ] Just inside.

Operate as follows:

 names = ['ada','amy','ella','sandy']

The list can contain objects of different types and also supports nesting:

a = ['a',567,['adc',4,],(1,2)]

This list contains strings and integers , tuple elements, and a list is also nested.

Modify the values ​​in the list

The list is ordered, and the value at a specific position can be modified through the python list subscript.

The following is an example of how to modify the list parameters:

>>>a = [1,9,9]
>>>a [0] = 9
>>>a
[9,9,9]

The modification operation of the list can also be regarded as the operation of reassigning a specific position.

For more Python related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of Is python list ordered?. 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