mediumMultiple Choice
200-901 Practice Question: A Python script uses the `requests` library to…
A Python script uses the `requests` library to fetch device details from Cisco DNA Center. The API returns a JSON response with nested objects. To extract the management IP address from the response stored in variable `data`, which code snippet is correct? The JSON structure is:
{
"response": [
{
"managementIpAddress": "192.168.1.1",
"hostname": "router1"
}
]
}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
✓
data['response'][0]['managementIpAddress']
The response contains a list under key 'response'; correct access is via data['response'][0]['managementIpAddress'].
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
data.managementIpAddress
Why it's wrong here
Accessing `data.managementIpAddress` treats the parsed JSON as an object with attributes, but `requests` returns dictionaries and lists, so the key sits at `data["response"][0]["managementIpAddress"]`. Attribute access suits libraries like `xmltodict` or custom objects; here it raises `AttributeError`.
- ✗
data['response']['managementIpAddress']
Why it's wrong here
Indexing `data['response']` yields a list, so subscripting it with the string `'managementIpAddress'` raises a `TypeError`; the list element must be selected first, as in `data['response'][0]['managementIpAddress']`. Chained key access suits JSON where each level is an object, not an array, which this response is not.
- ✗
data.get('response')[0].get('managementIpAddress')
Why it's wrong here
Bracket indexing is required: data['response'] returns the list, then [0]['managementIpAddress'] extracts the nested value. The .get() method returns None for missing keys rather than raising KeyError, which is why it is preferred for optional fields — but here the keys exist and .get() on a list element still needs the index, so the syntax is valid only if response is guaranteed present.
- ✓
data['response'][0]['managementIpAddress']
Why this is correct
Accessing `data['response']` yields the JSON array, and `[0]` selects its first element, the device object. Indexing that dictionary with `['managementIpAddress']` returns the nested string "192.168.1.1". This directly satisfies the stem's requirement to extract the management IP from the nested structure.
Go deeper
Related to this question
About these practice questions
One of 975 original 200-901 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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.