Question: python language, practice with dictionaries and lists i had asked this question previously and this is the answer that someone gave me, which is not

python language, practice with dictionaries and lists

python language, practice with dictionaries and lists i had asked this questionpreviously and this is the answer that someone gave me, which is

i had asked this question previously and this is the answer that someone gave me, which is not working. they added "class letmeinn(object)" before the function but i cannont change or add anything to the given function which is "def hotel_manager(room_prices,room_counts,reservations):"

this is the code below that was given and is not working:

not working. they added "class letmeinn(object)" before the function but i cannont

You are the manager of the Let Me Inn. A travel agent has sent you a list of reservations that can be accommodated by the hotel. Your primary job is to send him back the total cost of the reservations. To make sure your hotel runs properly, you also will keep track of how much money you have made from each type of room (Normal, Double, King, Suite) Complete the function hotelmanager which takes arguments in the following order: 1. room_prices: A dictionary that maps a type of room (a string) to the price of the room (an integer) 2. room.counts: A dictionary that maps a type of room (a string) to the number of available rooms of that type (an integer) 3. reservations: A list of sub-lists wherein the first element of a sub-list contains the type of room being reserved, and the second element is the desired count of rooms of that type. For example, the sub-list ['King', 3] would indicate that 3 King rooms are desired. The function iterates over the reservations list, extracting the room type and room count of each reservation. Room types can appear multiple times in the list. Then, the function looks up the price of the desired room using the room.prices dictionary and determines what it would cost to reserve the desired number of rooms. You may assume that the room type in the reservation always has a corresponding price in room.prices and a corresponding count in room.counts If there are enough available rooms to accept the reservation, the function (1) updates the total income generated by the reservation, (2) updates room.counts to reflect that fewer rooms are now available, and (3) updates a dictionary that tracks how much income was generated by each type of room. As an example, suppose that a King room costs $200 per night and 3 have such rooms been successfully reserved. Suppose also that we have created a dictionary called room.incomes to store the income generated by each room type. In this example, the function would add 600 both to roomincomes ['King'] and to the total income generated. It would also subtract 3 from room.counts['King' ]

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!