count() to get number of matching items

All list methods

count() takes one argument.

returns number of matching value.
my_list=['a','b','c','b','a','d']
print("Number of times a appears : ", my_list.count('a'))
print("Number of times b appears : ", my_list.count('b'))
print("Number of times c appears : ", my_list.count('c'))
Output
Number of times a appears :  2
Number of times b appears :  2
Number of times c appears :  1
All list methods Questions with solutions on List pop() to remove item based on position
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer