← 2023 questions

2023 / GRAB / QUESTION 21

Restaurant categories

Try the question in your own editor, then check your output below.

THE QUESTION

Tristan is feeling hungry, he wants to eat something from: Restaurant Food, Fast Food, Beverages. Create a function which asks Tristan what he feels like eating. Then, from the list below, display the options based on what he wants to eat.

Starter Code:

grab = [{"Restaurant": "Esquire Kitchen",
"Category":"Restaurant Food"},
{"Restaurant": "McDonalds","Category":"Fast Food"},
{"Restaurant": "KFC", "Category":"Fast Food"},
{"Restaurant": "Jin Xuan Hong Kong",
"Category": "Restaurant Food"},
{"Restaurant": "Gong Cha", "Category": "Beverages"},
{"Restaurant": "Boost Juice", "Category": "Beverages"},
{"Restaurant": "Sushi Zanmai","Category":"Restaurant Food"},
{"Restaurant": "Yomie's Rice X Yogurt",
"Category":"Beverages"}]

Question by Natalie. Source: Girls In Code SEA — Behind the Screens, 2023, slide 38.

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Use input Fast Food. Enter the matching restaurant names as a list or one per line.

Reveal worked answer

Fast Food · one valid answer

["McDonalds", "KFC"]

Filter the dictionaries where Category equals Fast Food.