Preparing Practice Exam…
Please wait a moment while the system generates the exam questions, answers, and study session.
Please wait a moment while the system generates the exam questions, answers, and study session.
Question 49 of 166
Free Preview · 166 of 552 · questions 1–166 of 552 are free. Sign up free to sync your progress across devices.
Select one answer.
Written by other learners. Comments can disagree with the marked answer — check the official documentation when in doubt.
The [0]['items'][0]['items'][0] exactly points to the -> "kiwi" 1. 0th element of response = first dictionary 2. then the "items" key 3. 0th list element of "items" is the nested dictionary 4. items is again a key inside it and at 0th indec inside the list is "kiwi"
it is kiwi but that function is very syntactically wrong 1) lambda functions can't be called integers, so it should be something like "lambda <name>: <name>["type'"] == ..." 2) filter() returns an iterator and is not directly subscriptable, meaning that you need to actually iterate over it: for item in filter(lambda name: name["type"] == "fruit", data): print(item) this returns: {'type': 'fruit', 'items': [{'color': 'green', 'items': ['kiwi', 'grape']}, {'color': 'red', 'items': ['strawberry', 'apple']}]} 3) [0]['items'][0]['items'][0] is also syntactically incorrect since the outer-most object is a dictionary not a list, however: for item in filter(lambda name: name["type"] == "fruit", data): print(item['items'][0]['items'][0]) does actually return "kiwi" another quality question from cisco
oh, i just noticed that i named my variable "data" instead of "vegetables"