Python 1-10 list

One, Python3 list

https://www.runoob.com/python/python-lists.html

Python 's list is an ordered and repeatable collection of elements, which can be nested, iterated, modified, fragmented, appended, deleted, and judged by members.

1. How to create

To create a list, simply enclose the different data items separated by commas in square brackets. The elements in the list can be any other type of data, the list can be nested in multiple layers, and the number of elements is unlimited.

>>> lis = []        # 创建一个空列表
>>> lis = [1, 2, 3]
>>> lis = [1, 'a', [11,22], {'k1':'v1'}]
>>> lis = [1, 2, [3, 4, 5]]

2. Access the elements in the list

 

Use the subscript index to access the values ​​in the list, the same you

Guess you like

Origin blog.csdn.net/weixin_43955170/article/details/112695296