Lecture 2, function arguments,Exercise

Hello,I can find the least amount (540),but can not write code to show which city it is.How can I add city to this line of codes?
Thank you

def vacation_plan(flight,hotel_cost,car_rent):

cost_of_trip = flight+(hotel_cost*7)+car_rent
cost_of_trip=math.ceil(cost_of_trip)
return cost_of_trip

cities=(Paris,London,Dubai,Mumbai)
Paris = vacation_plan(200,20,200)
London = vacation_plan(250,30,120)
Dubai = vacation_plan(370,15,80)
Mumbai = vacation_plan(450,10,70)
least_amount_of_money=min(cities)

You cannot find the city name with directly with min() function.

  1. Try to create a new function which gives you the min cost and city name.
  2. Or you can can replace the set (cities) you made with list or dictionaries.

import math

cities={

‘Paris’:vacation_plan(200,20,200),

‘London’:vacation_plan(250,30,120),

‘Dubai’:vacation_plan(370,15,80),

‘Mumbai’:vacation_plan(450,10,70),

}

#Step 1: Convert dictionary keys and values into lists.

key_list=list(cities.keys())

print(key_list)

val_list=list(cities.values())

print(val_list)

#Step 2: Find the matching index from value list.

city=val_list.index(min(val_list))

print (city)

key_list[city]