Python Programming - Data Types - Discussion

Discussion Forum : Data Types - General Questions (Q.No. 41)
41.
What is the purpose of the count() method in Python lists?
To find the total number of elements in the list
To count the occurrences of a specific element in the list
To reverse the order of elements in the list
To add an element to the end of the list
Answer: Option
Explanation:

The count() method is used to count the number of occurrences of a specified element in a list.

Here is an example program that uses the count() method:

list = [1, 2, 3, 4, 1, 2]
print(list.count(1))

This program will print the number 2, which is the number of times the element 1 appears in the list.

Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.