The common data structures in Python can be collectively referred to as Containers (container). sequences (such as lists and tuples), mappings (such as dictionaries), and collections (set) are the three main types of containers. First, sequence (list, tuple, and string)
Each element in the sequence has its own number. There are 6 types of built-in sequences in Python. where lists and tuples are the most common types. Other include strings, Unicode strings, buffer objects, and Xrange objects. The following tables, tuples, and strings are highlighted below. 1, List
The list is variable, which is the most important feature that distinguishes it from strings and tuples: The list can be modified and the strings and tuples cannot. (1), create
You can create a list in the following ways:
| 1 2 3 4 |
List1 = [' Hello ', ' world '] print list1 list2 = [1, 2, 3] Print List2 |
Output:
[' Hello ', ' world ']
[1, 2, 3]
As you can see, this is created in a way that is very similar to an array in JavaScript.
(2), List function
The list function (in fact the list is a type rather than a function) is useful for creating lists of strings:
| 1 2 |
LIST3 = List ("Hello") print List3 |
Output:
[' H ', ' e ', ' l ', ' l ',