Hi. I have created a dictionary in python using lists. Now I want to find the length of the list. I tried doing this
But it didn’t work. How can I get the count of values?
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())
There are several options. Here is a ...READ MORE
To count the number of elements of ...READ MORE
The Average Case assumes parameters generated uniformly ...READ MORE
You can find factorial by many ways. ...READ MORE
You can also use the random library's ...READ MORE
colors = ['red', 'green', ...READ MORE
can you give an example using a ...READ MORE
You can simply the built-in function in ...READ MORE
You can use a combination groupby function with the sum() method. ...READ MORE
Yes you can do it using the ...READ MORE
Already have an account? Sign in.