How to find count/length of dictionary values of list?

0 votes

Hi. I have created a dictionary in python using lists. Now I want to find the length of the list. I tried doing this

len(d.values())

But it didn’t work. How can I get the count of values?

May 13 in Python by Sharan
22 views

1 answer to this question.

0 votes

You should have used d.itervalues() instead and then used a loop to calculate the sum. Try this:

count = sum(len(v) for v in d.itervalues())
answered May 13 by John

Related Questions In Python

+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,720 points
91 views
0 votes
1 answer

How to count the number of elements in a list?

To count the number of elements of ...READ MORE

answered May 27 in Python by Nisa
• 1,090 points
33 views
0 votes
1 answer

How to find runtime complexity of funtions that use list in Python?

The Average Case assumes parameters generated uniformly ...READ MORE

answered Jul 26 in Python by Arvind
• 2,960 points
34 views
0 votes
1 answer

how to find factorial of a number?

You can find factorial by many ways. ...READ MORE

answered May 4, 2018 in Python by aayushi
• 750 points
50 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 424 views
+4 votes
6 answers
0 votes
1 answer

How to find the sum of rows in Pandas dataframe?

You can use a combination groupby function with the sum() method. ...READ MORE

answered May 9 in Python by Jisha
579 views
0 votes
1 answer

How to find exponent of a number in Python?

Yes you can do it using the ...READ MORE

answered Jul 2 in Python by Arvind
• 2,960 points
37 views