Courseiva
easyMultiple ChoiceObjective-mapped

200-901 Dictionary indexing Practice Question

A developer is writing a Python script that uses the Cisco Catalyst Center (formerly DNA Center) API to get the list of sites. The API returns a response with a 'response' key containing a list of sites. The developer wants to access the 'response' field from the JSON response. Which code snippet correctly extracts the list?

⚠ Common exam trap

Candidates may think that only direct indexing is correct, but `.get()` is also a valid Python method for accessing dictionary keys. The trap is to overlook `.get()` as a viable option.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

sites = response['response']

Uses direct dictionary indexing `response['response']`, which is the most direct way to access the 'response' key. Option D uses the `.get('response')` method, which also retrieves the value for the key 'response' and is safe in case the key is missing (returns None instead of raising KeyError). Both methods are correct in this context because the API is expected to return a dictionary with a 'response' key. Options A and C are incorrect because they treat the response object as a list or attempt to index it incorrectly.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • sites = list(response)

    Why it's wrong here

    Incorrect because `list(response)` converts the dictionary keys to a list, not the value of the 'response' key.

  • sites = response['response']

    Why this is correct

    Correct. Direct dictionary indexing retrieves the list of sites from the 'response' key.

  • sites = response[0]

    Why it's wrong here

    Incorrect because `response[0]` attempts to index the dictionary by integer, which would raise a KeyError.

  • sites = response.get('response')

    Why this is correct

    Correct. The `.get('response')` method safely retrieves the value for the 'response' key, returning the list of sites.

About these practice questions

This 200-901 question is part of Courseiva's 989-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.