Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to manipulate the list in Python

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces you how to operate the list in Python, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Code implementation

My_list = [] # created an empty list print (my_list, type (my_list))

My_list = [10] # create a list print (my_list) that contains only one element

My_list = [10, 20, 30, 40, 50] # creates a list print (my_list) that protects 5 elements.

# any object my_list can be saved in the list = [10, print, 2, 3], print (my_list)

My_list = [10, 10, 20, 30, 40, 50] print (my_list)

# the value of the length obtained, which is the maximum index of the list + 1print (len (my_list)) # 5

Code run output:

[]

[10]

[10, 20, 30, 40, 50]

[10, 'hello', True, None, [1,2,3],]

[10, 20, 30, 40, 50]

five

This is the end of the list of how to operate in Python. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report