How to realize the General Operation of list in Python
Today, I will talk to you about how to achieve the general operation of the list in Python, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
Code implementation
# list stitching my_list = [1Power2Power3] + [4Power5Power6] print ('the list after stitching is:', my_list) # repeating list my_list = [7pc8, my_list] * 3print ('list after repeating 3 times is:', my_list) # create list stus = ['Sun WuKong', 'Zhu Bajie', 'Sha Wujing', 'Tang monk', 'spider essence', 'Baigujing', 'Sha Wujing' 'Sha Wujing'] # find whether the element is in the list print ('determine whether the spider sperm is true in stus:', 'spider spirit' in stus) print ('judge whether the Bull Devil King is not true in stus:', 'Bull Devil King' not in stus) print ('statistics on the number of uranium Sha Wujing in stus:', stus.count ('Sha Wujing')) print ('stus length is:' Len (stus)) # find the minimum and maximum values in the list my_arr= [10, max 3, 2, 4, 222] print ('minimum in my_arr:', min (my_arr)) print ('maximum in my_arr:', max (my_arr)
Code run output:
The stitched list is [1, 2, 3, 4, 5, 6]
Repeat 3 and the following list is: [7, 8, 9, 7, 8, 9, 7, 8, 9]
Determine whether the spider essence is true in stus: True
Determine whether the Bull Devil King is not in stus is true: True
Statistics of several uranium in stus Sha Wujing: 3
The length of stus is: 8
The minimum value in my_arr is: 2
The maximum value in my_arr is: 222
After reading the above, do you have any further understanding of how to implement list common operations in Python? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.