python - How to count the number of values associated with a key -
Looking at the following dictionary, I want to know which key is the highest value if I have a long term dictionary And I want to know which key is programmatically the most important value (without visual inspection), how would I do it? The only way I can think of is as follows:
dick = {'attacks': [' kick ',' patch ',' slap ',' elbow '],' rescue : ['Kik', 'patch', 'slap', 'elbow']: ['block', 'parry', 'dodge']}
dike = 'defense' : '' '' '' '' '' '' Key for IT for IT in IT]: num + = 1 key_values_list.list (for key, num)), in key_values_list v: print k, v < / Code>
The following code will count the examples of labeled label attacks:
gt; & Gt; Maximum for Kashmir ((Kashmir, Lan (V)), in dic.items (), v = lambda x: x [1]) ('attacks', 4) & gt; & Gt; & Gt;
Comments
Post a Comment