Python Expensive Menu Recommendation for Affordable Menu

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

menu = "ham bread chicken egg"
prices = "1200 5000 17000 500"

I'd like to know how to print out the most expensive and cheap menu given like this. I'm going to use min and max, but it's divided into menu and prices, so I don't even know what to do. I'd appreciate it if you could help me as a beginner.

The cheapest menu: egg  
Most expensive menu: chicken  

python

2022-09-20 10:53

1 Answers

Hello.

If you divide each string into spaces and save each string as an array, you will have information about the same menu in the same order.

menu = "ham bread chicken egg"
price = "1200 5000 17000 500"
# Do it like this and that. Change it to the following. Hint: split
menus = ["ham", "bread", "chicken", "egg"]
prices = ["1200", "5000", "17000", "500"]

If you transform the data into the above form, the price of menus[i] is prices[i].

It won't be difficult to get the maximum/minimum value when you know the price for each menu. There's got to be a lot of course.


2022-09-20 10:53

If you have any answers or tips


© 2022 pinfo. All rights reserved.