Restaurant

Report a typo

Imagine you are having dinner in a very fancy restaurant, but unfortunately you don't have a lot of money with you. You want to have a main course, a dessert and a drink, but all that together shouldn't cost more than $30.

The names of the main courses, desserts and drinks are stored in the lists main_courses, desserts and drinks respectively. The corresponding prices can be found in the lists price_main_courses, price_desserts and price_drinks.

Consider each possible combination of a main course, dessert and a drink from those offered by the restaurant and print out only those meals that satisfy your budget, along with their total costs.

For instance, imagine the dishes and prices are as defined below:

main_courses = ['beef stew', 'fried fish']
price_main_courses = [28, 23]

desserts = ['ice-cream', 'cake']
price_desserts = [2, 4]

drinks = ['cola', 'wine']
price_drinks = [3, 10]

Then, your output should be the following:

fried fish ice-cream cola 28
fried fish cake cola 30

Use zip() to simultaneously iterate over the tuples of the dishes and the tuples of their prices.
Write a program in Python 3





___

Create a free account to access the full topic