Hi! I’m stuck trying to figure it out how to create a function for the question number 3
3. If your total budget for the trip is
$1000, which city should you visit to maximize the duration of your trip? Which city should you visit if you want to minimize the duration?
I solved the previous questions this way:
# Exercise 1 paris = [200, 20, 200] london = [250, 30, 120] dubai = [370, 15, 80] mumbai = [450, 10, 70] def cost_of_trip(flight, hotel, car): cost = flight + hotel * 7 + car return cost print(cost_of_trip(*paris), ': Paris') # the '*' unpacks the list to arguments for the function print(cost_of_trip(*london), ': London') print(cost_of_trip(*dubai), ': Dubai') print(cost_of_trip(*mumbai), ': Mumbai') # You should visit Paris to spend the least amount of money in a week
# Exercise 2 import math def cost_of_trip(flight, hotel, car, days): '''calculates the cost of the trip taking into account the number of days''' car_cost = car * math.ceil(days/7) cost = flight + hotel * days + car_cost return cost