Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume that you are considering booking accommodation for a 1 - week stay in Hong Kong on Airbnb, and you have multiple potential targets (

Assume that you are considering booking accommodation for a 1-week stay in Hong Kong on Airbnb, and you have multiple potential targets (e.g., dozens) under consideration.
Note that every accommodations on Airbnb is rated on a 5-star scale for each of the following 8 categories: Overall experience,cleanliness, accuracy, check-in, communication, location, value, and amenities.
Now, suppose that you manage to obtain the rating data for your target rentals, and maintain it in a Python list as follows:
```
ratings =[[3,4,4,5,5,3,5,3],
[5,5,5,3,4,4,4,5],
[3,5,5,2,4,4,5,2],
[5,5,5,5,3,2,4,5],
[4,5,3,3,3,4,2,4],
[4,5,3,3,2,3,2,5],
[3,4,3,4,3,4,5,4]]
```
where each sublist represents the ratings across 8 categories for one potential rental.
Write Python code (preferrably a comprehension) to create a list that contains the indices of accommodations that receive the highest rating for each category.
The expected output should look like the following:
```
[[2,4],[2,3,4,5,6],[2,3,4],[1,4],[1],[2,3,5,7],[1,3,7],[2,4,6]]
```

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

Students also viewed these Databases questions

Question

What would you do?

Answered: 1 week ago