Define a function called restaurant_price that takes one argument, a Restaurant, and returns the value of the price field of that Restaurant. So define a list containing a few Restaurants
I keep getting the error of Restaurant not defined.
This is my code:
def restaurant_price (Restaurant:Restaurant)-> float:
return Restaurant.price
from collections import namedtuple
Restaurant = namedtuple('Restaurant', 'name cuisine phone dish price')
RC = [
Restaurant("Thai Dishes", "Thai", "334-4433", "Mee Krob", 12.50),
Restaurant("Nobu", "Japanese", "335-4433", "Natto Temaki", 5.50),
Restaurant("Nonna", "Italian", "355-4433", "Stracotto", 25.50),
Restaurant("Jitlada", "Thai", "324-4433", "Paht Woon Sen", 15.50),
Restaurant("Nola", "New Orleans", "336-4433", "Jambalaya", 5.50),
Restaurant("Noma", "Modern Danish", "337-4433", "Birch Sap", 35.50),
Restaurant("Addis Ababa", "Ethiopian", "337-4453", "Yesiga Tibs", 10.50) ]
assert restaurant_price(RC[1]) == 5.50
Then I need help on this second question: Write a sequence of statements that prints out the list of Restaurants RC in order from least expensive to most expensive (best dish).
print(RC.sort(key=restaurant_price))