Courseiva
mediumMultiple ChoiceObjective-mapped

200-901 Practice Question: A developer is designing a Python script to parse…

A developer is designing a Python script to parse the output of 'show ip interface brief' from a Cisco IOS device. The output is stored in a string variable. The developer wants to extract only the interfaces that are up/up. The current code uses regular expressions but often fails because the interface names contain special characters (e.g., GigabitEthernet1/0/1). Which approach should the developer use to reliably parse the output?

⚠ Common exam trap

Candidates often assume regex or string splitting is always sufficient for parsing CLI output, overlooking that Cisco devices can natively output structured data formats like JSON, which is the recommended method for reliable parsing in network automation.

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

Use a structured data format like JSON or YAML if available from the device

Cisco IOS devices can output structured data formats like JSON or YAML when commands are prefixed with 'pipe' modifiers (e.g., `show ip interface brief | json`). Parsing structured data eliminates the need for fragile regex patterns that fail on interface names containing special characters like slashes or hyphens. This approach is more reliable and maintainable, aligning with modern network automation practices.

Answer analysis

Option-by-option breakdown

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

  • Use the 're' module with a more complex pattern that escapes special characters

    Why it's wrong here

    While possible, regex is brittle and hard to maintain; structured output is preferred.

  • Use split on whitespace and check column values

    Why it's wrong here

    This may work for simple lines but fails if interface names contain spaces or if column alignment changes.

  • Use a structured data format like JSON or YAML if available from the device

    Why this is correct

    Structured output is consistent, machine-readable, and immune to formatting changes.

  • Use a CSV parser with a custom delimiter

    Why it's wrong here

    The output is not CSV; there is no consistent delimiter.

About these practice questions

One of 989 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 →

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.