Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help! The code below is meant to count the number of times each genre appears in the list below. However, the code has some critical

Help! image text in transcribed

The code below is meant to count the number of times each genre appears in the list below. However, the code has some critical errors. Fix the code so that it correctly counts genres and prints the result. Execution: Idle Printer Feedback: Instructor Feedback You have created a dictionary to count elements, but it is not counting genres. Instead, it only has one key for the literal value 'genre , as opposed to keys for values like 'Horror or 'Comedy Trace Variables 'genre': 1 Run | Blocks ?Split / Text ?Reset ) Upload | ? E History books_genres["Horror", "Sci-Fi", "Horror", "Comedy", "Comedy", "Horror", "Horror", "Comedy" 3 genre_countsf) 4 for genre in books_genres: if genre in genre_counts: genre-counts["genre"J genre-counts ["genre"] + 1 - else: genre_counts["genre"] 1 9 print genre_counts)

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

Pro Oracle Fusion Applications Installation And Administration

Authors: Tushar Thakker

1st Edition

1484209834, 9781484209837

More Books

Students also viewed these Databases questions