how can i count the items in a list

+1 vote
can you give an example using a sample list having numbers from 0-10.
May 2, 2019 in Python by Waseem
• 4,540 points

2 answers to this question.

+1 vote
suppose you have a list

a = [0,1,2,3,4,5,6,7,8,9,10]

now if you want to count the items in your list. you should have a value at your disposal

suppose you want to check the count the number of times 2 is in your list.


it will give you the count.

In this case if you want the number of items in your list you can just check the length


it will give you the number of items in your list.
answered May 2, 2019 by Mohammad
• 3,210 points
+2 votes

Syntax :

           list. count(value)


colors = ['red', 'green', 'blue', 'black']

Return the number of times the value' blue' appears int in the colors list

x= colors.count("blue")
Output: 1
answered Jul 6, 2019 by Neha
• 330 points

edited Jul 8, 2019 by Kalgi

Related Questions In Python

0 votes
2 answers

How can I get the count of a list in Python?

n=[1,2,3,4,5,6,7,8,9] print(len(n)) =9 READ MORE

answered Dec 10, 2020 in Python by anonymous
+2 votes
2 answers

In a list of dictionaries, how can I find the minimum calue in a common dictionary field.

There are several options. Here is a ...READ MORE

answered Apr 10, 2018 in Python by charlie_brown
• 7,780 points
0 votes
1 answer
0 votes
1 answer

How can I count the occurrences of a list item?

If you only want one item's count, ...READ MORE

answered Dec 18, 2020 in Python by Gitika
• 65,850 points
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
0 votes
2 answers
0 votes
0 answers
0 votes
1 answer