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, 2019 in Python by Sharan
2,396 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, 2019 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
1,406 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, 2019 in Python by Nisa
• 1,090 points
5,237 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, 2019 in Python by Arvind
• 3,050 points
756 views
0 votes
1 answer

How to list a column of float values from csv file without importing (Python)

Using the default CSV module Demo: import csv with open(filename, "r") ...READ MORE

answered Sep 16, 2020 in Python by Rajiv
• 8,870 points
8,934 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,422 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,042 views
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, 2019 in Python by Jisha
4,602 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, 2019 in Python by Arvind
• 3,050 points
2,299 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP