What does this content-block parser print?

from Claude API
Claude Developer Platform (2026-09) beginner 2 min

What does this content-block parser print?

Python
message = {
    "content": [
        {"type": "text", "text": "Ready"},
        {"type": "tool_use", "name": "lookup", "input": {}},
    ]
}
texts = [b["text"] for b in message["content"] if b["type"] == "text"]
calls = [b for b in message["content"] if b["type"] == "tool_use"]
print("".join(texts), len(calls))
Open in playground
Report an error