PIXELBANKv9.1.0
Menu

Parse structured key-value output from an LLM response.

LLMs often produce structured output with labeled fields. Parse a response into a dictionary where each line has the format "Key: Value".

Input:

  • Multi-line text (each line is "Key: Value")
  • Last line: comma-separated list of required keys

Output: For each required key (in order given), print the value. Print "MISSING" for keys not found.

Matching is case-insensitive for keys. Extra whitespace should be stripped.

Example:

Input:
Name: Alice
Age: 30
City: New York
Name,Age,Email
Output:
Alice
30
MISSING
Reasoning:
  • The input is parsed into a dictionary with case-insensitive keys, resulting in: name: Alice, age: 30, city: New York
  • The last line is split into a list of required keys: Name, Age, Email
  • For each required key, the corresponding value is looked up in the dictionary, with case-insensitive matching, and printed: Alice for Name, 30 for Age
  • Since Email is not found in the dictionary, MISSING is printed for that key

Constraints:

  • Key matching is case-insensitive
  • Strip whitespace from keys and values
  • Lines without ":" are skipped
  • Required keys are comma-separated on the last input line
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.