Python3 Base List Method Count query specifies how many times the element appears in the list

Source: Internet
Author: User
Tags ming

Town Field Poem:
Cheng listens to the Tathagata language, the world name and benefit of Dayton. Be willing to do the Tibetan apostles, The broad show is by Sanfu Mention.
I would like to do what I learned, to achieve a conscience blog. May all the yimeimei, reproduce the wisdom of the Body.
——————————————————————————————————————————

Ex1:
Code

members=[[' Beidou Yang Wang greedy Wolf star June ', ' Beidou Yin Jing giant gate star June '],[' Beidou life Lu save star June ', ' Beidou Xuan Ming wen qu Xing June ', [' Beidou dan yuan-june Wang ', ' Beidou Polar Star June ', ' beidou, Guan June June ' star ']]print (members) Print () #换行 # list expanded to three times times members*=3# it seems that count can only query the elements of the list, not the elements of the list of queries list (members.count (' Beidou-day-broken Army star June ')) #这样就可以了print ( Members[2].count (' Beidou Day close the Army star June ')


Result

Ex2:

Code

#看下面的列子newmember =[' Beidou yangming Wolf star June ', ' Beidou Yin Jing giant door star June ', ' Beidou Life Lu save star June ', ' Beidou Xuan Ming wen qu Xing June ', ' Beidou dan Yuan-june ' star ', ' Beidou Polar Star June ', ' Beidou day close Broken Army star June ']print ( Newmember.count (' Beidou Day close the Army star June ') "#扩充为原来的三倍newmember *=3print (newmember.count (' Beidou Day Guan June)")


Result


——————————————————————————————————————————
The essence of the blog, in the technical part, more in the town yard a Poem. Python version 3.5, system Windows7.
Python is a good language and deserves to be studied Hard. I am following the small turtle Video tutorial to learn, Recommended.
I am a novice, so if the content of the blog can be improved, or even the wrong place, please leave a comment, I will try to correct, strive to achieve a conscience blog.
Note: This article is only as a scientific research study, if I inadvertently violated your rights and interests, please be sure to timely inform, I will make Corrections.

Python3 Base List Method Count query specifies how many times the element appears in the list

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.