Question: I need help with this: CAN NOT use lamda Function: find_airbnb Parameters: airbnb list (list of tuples), number of people (int), max price (float) Returns:

I need help with this: CAN NOT use lamda

Function: find_airbnb Parameters: airbnb list (list of tuples), number of people (int), max price (float) Returns: A tuple

Description: As a broke college student, you want to be able to stay in the best airbnb as possible but also stay in the airbnb that is affordable for you. You also want to be able to find an airbnb that will fit you and all your friends. Write a function called find_airbnb that takes in a list of airbnb tuples in the format (NAME, CAPACITY, RATING, PRICE_PER_NIGHT). The airbnb must be able to fit everyone in your party and be within your price range. If multiple apartments fit these requirements, return the one with the highest rating. No airbnbs with the same capacity will ever have the same rating. Return a tuple with the name of the airbnb (string) and the price that each person in your group will pay per night (float rounded to two decimal places). Also, if no airbnbs satisfy the conditions, then return an empty tuple.

Note: If two airbnbs are both below the price range, then you should return the one with the highest rating.

Test Cases: >>> list1 = [("Hawaiian Luau", 10, 4.5, 500), ("Hawaiian Mist", 7, 3.5, 350), ("Mountain Melody", 2, 5.0, 600), ("North Ave Apartments", 15, 1, 200)] >>> test1 = find_airbnb(list1, 6, 400) >>> print(test1) ('Hawaiian Mist', 58.33)

>>> list2 = [("Island Paradise", 2, 5.0, 500)] >>> test2 = find_airbnb(list2, 10, 200) >>> print(test) ()

this is what i ahve:

##def find_airbnb(airbnb_list,num_people,max_price): ## highest_rate = airbnb_list[0][2] ## highestname = airbnb_list[0][0] ## for i in airbnb_list: ## (name,occ,rate,price) = i ## if int(occ) >= int(num_people): ## if float(price) <= float(max_price): ## if rate > highest_rate: ## highest_rate = rate ## highestname = name ## price_per_person == price / num_people ## tuplist = tuple(highestname,price_per_person) ## return tuplist ## ## ##list1 = [("Hawaiian Luau", 10, 4.5, 500), ("Hawaiian Mist", 7, 3.5, 350), ("Mountain Melody", 2, 5.0, 600), ("North Ave Apartments", 15, 1, 200)] ##test1 = find_airbnb(list1, 6, 400) ##print(test1)

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!