Parse a GitHub-Style API Response
Given a JSON string that represents what a GitHub API response would look like (i.e. what response.json() would return), parse it and print the user's public repo count.
Why not a real network call? an automated judge can't reliably reach the internet, and even if it could, a live API's data changes over time — so this exercises the exact same skill (reading fields out of a parsed JSON API response) using a fixed, given response instead of a live one.
Approach: json.loads() parses the JSON string into a Python dict, exactly like response.json() would; then read the field you need.
Input: One line: a JSON object (as text) with at least a public_repos field.
Output: One line: the value of public_repos.
{"login": "octocat", "public_repos": 8}8
- The input is always valid JSON with a public_repos field.
Hint 1
json.loads(text) converts a JSON string into a Python dict, the same shape response.json() would give you from a real API call.
Hint 2
Once parsed, reading a field is just normal dictionary access: data["public_repos"].
json.loads(raw) parses the given JSON text into a Python dict exactly the way response.json() would after a real GitHub API call — the rest of the problem is just ordinary dictionary field access, data["public_repos"].