Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python dictionary, get the count of elements. my_dict= { ... 'Barbara': ['blue', 5], 'Betty': ['purple', 8], 'Brian': ['orange', 7], 'Carol': ['green', 1], 'Charles': ['green', 9],

Python dictionary, get the count of elements.

my_dict= {

...

'Barbara': ['blue', 5], 'Betty': ['purple', 8], 'Brian': ['orange', 7], 'Carol': ['green', 1], 'Charles': ['green', 9], 'Christopher': ['pink', 2], 'Cynthia': ['blue', 1], 'Daniel': ['blue', 10], 'David': ['purple', 7], 'Deborah': ['red', 6], 'Donald': ['gray', 7],

...

}

contains names, colors, and numbers, I'm looking for code that will count the instances of each color and number(1 to 10), so for this excerpt the output might be:

color: instances:

blue:3 purple: 2 orange: 1 green: 2 pink: 1 red: 1 gray: 1

numbers: instances:

1: x 2: x 3: x 4: x 5: x 6: x 7: x 8: x 9: x 10: x

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

A motor will overheat quickest when it is

Answered: 1 week ago