Home > Backend Development > Python Tutorial > What are the differences between lists, tuples, and dictionaries in Python?

What are the differences between lists, tuples, and dictionaries in Python?

王林
Release: 2020-07-17 11:16:40
Original
26263 people have browsed it

The differences between lists, tuples, and dictionaries in python are: 1. Tuples are immutable, while lists and dictionaries are mutable; 2. Lists cannot be used as key values ​​in dictionaries, while tuples are immutable. Groups are OK, and the keys of the dictionary are unique; 3. Tuples represent structures, while lists represent order.

What are the differences between lists, tuples, and dictionaries in Python?

The differences between lists, tuples, and dictionaries are as follows:

(Recommended tutorial: python tutorial )

1. Tuples are immutable, while lists and dictionaries are mutable

Tuples are immutable objects. Once the object is generated, its value cannot be changed. ; A list is a mutable object. After the object is generated, its elements can be changed, added, deleted, cleared, sorted, etc.

2. Tuples are usually composed of different data, while lists are the same data queue

Tuples represent structures, while lists represent sequences. Lists have far greater permissions than tuples.

3. Lists cannot be used as dictionary key values, but tuples can. Dictionary keys are unique.

The above is the detailed content of What are the differences between lists, tuples, and dictionaries in Python?. 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