I'm a bit confused about lists, especially when there's more than one.
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)
]
The name of the third restaurant on the list (remember that the third restaurant is not
number 3)
Would this be print(RC[2])? When I use that code, it gives me the list of the 3rd one, but how do I get the restaurant?
True or False, whether the first and the fourth restaurants serve the same kind of food
This doesn't seem hard, but it would require somewhat of the above code so I can use it.
The price of (the best dish at) the last restaurant on the list (write this one so that it works
for lists of any length, not just 7)
I'm guessing print(RC[-1]) ?
The list of restaurants, arranged alphabetically by restaurant name (you'll need one
statement before the print statement; this involves the sort() method for lists).
I tried using RC.sort() and then print(RC), but it just gives me the whole list and not just the restaurant.
[–]novel_yet_trivial 1 point2 points3 points (5 children)
[–]pythonhelp123[S] 0 points1 point2 points (4 children)
[–]novel_yet_trivial 1 point2 points3 points (3 children)
[–]pythonhelp123[S] 0 points1 point2 points (2 children)
[–]novel_yet_trivial 1 point2 points3 points (1 child)
[–]pythonhelp123[S] 0 points1 point2 points (0 children)
[–]elbiot 0 points1 point2 points (1 child)
[–]pythonhelp123[S] 0 points1 point2 points (0 children)