Question: Python program {1: [{4: 1}, {2: 1}, {1: 1}, 3], 2: [{4: 1}, {3: 1}, {1: 1}, 2], 3: [{4: 1}, {3: 1}, {1: 1},
Python program
{1: [{4: 1}, {2: 1}, {1: 1}, 3],
2: [{4: 1}, {3: 1}, {1: 1}, 2],
3: [{4: 1}, {3: 1}, {1: 1}, 2],
4: [{1: 1}, {3: 1}, {4: 1}, 2],
5: [{2: 1}, {3: 1}, {4: 1}, 1],
6: [{2: 1}, {1: 1}, {3: 1}, 4]}
I have this nested dictionary as shown above, I assigned value of 1 to all the first 3 numbers in the list. What i want is a function that input this dictionary and counts for example how many time number 4 has a value 1. So in this dictionary 4 has had a value of '1' 5 times. I want to tally that each number in the list from 1 -4 how many times each number had a value of 1 and then find the number that had the highest time value of 1 is the winner. The point here is all i can input to my function is this nested dictionary so I need my function to be able to break it down without having any manual input from me.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
