In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to understand the general operation of lists in Python". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to understand the routine operation of lists in Python.
Catalogue
1. An introduction to the list
two。 Print out the data of the list
1. We can print according to the subscript value.
two。 Traversing using for loops
3. Traversing using while loops
3. Add operation of list
1.append () method
2.extend () method
3.insert () method
4. List modification operation
5. Lookup operation of list
1.in method
2.not in method
3.index method
4.count method
6. Delete operations in the list
1.del method
2.pop method
3.remove method
7. Sort operation of list
8. A little exercise is for you.
(1)
(2)
1. An introduction to the list
Format of list: the type of variable An is list
NamesList = ['xiaoWang','xiaoZhang','xiaoHua']
The elements in the list can be of different types
For example: testlist= [1]
two。 Print out the list of data 1. We can print namesList = ['xiaoWang','xiaoZhang','xiaoHua'] print (namesList [0]) print (namesList [1]) print (namesList [2]) according to the subscript value.
two。 Use the for loop to iterate through namesList = ['xiaoWang','xiaoZhang','xiaoHua'] for i in namesList: print (I)
3. Use the while loop to iterate through namesList = ['xiaoWang','xiaoZhang','xiaoHua'] length=len (namesList) i=0while I
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.