Question: 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! Help! The code below is meant to count the number of times

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!