Is python list ordered?

(*-*)浩
Release: 2019-08-01 10:29:16
Original
6494 people have browsed it

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']
Copy after login

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

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

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]
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!