Home / Challenges / Parse a JSON API Response

Parse a JSON API Response

Medium
You are given a Python dictionary representing a JSON API response with a list of users under the key "users", where each user has "name" and "active" keys. Write a function active_user_names(data) that returns a list of names of users where active is True.

Input

A dict like {"users": [{"name": "Alice", "active": True}, {"name": "Bob", "active": False}]}

Output

A list of names of active users.

Example

Input
{"users": [{"name": "Alice", "active": True}, {"name": "Bob", "active": False}, {"name": "Carl", "active": True}]}
Output
['Alice', 'Carl']
15 XP on solve Back to lesson

Your Solution

Output
Click "Run" to execute your code...

Log in to submit your solution and earn XP.