runtime
79 / 500
question 79 Dictionaries & Sets · medium

Check user records from an API

An API returns users as a dictionary from user ID to a record. Before importing them, check each record and print one line per problem: <id>: missing email when there is no email key or it is blank, <id>: bad email when the email has no @, <id>: missing age when there is no age key, and <id>: age <n> out of range when the age is below 13 or above 120. A user can have an email problem and an age problem. Finish with <k> of <n> users valid.

Inputusers, a dictionary from user ID to a dictionary that may hold "email" (text) and "age" (a whole number)
Printsthe problem lines in user order (email before age), then <k> of <n> users valid
Valid ages13 to 120, both included
Examplesthe starter's users print problems for U02, U03 and U04, then 1 of 4 users valid
Expected output6 lines
  1. 1U02: missing email
  2. 2U02: age 9 out of range
  3. 3U03: missing email
  4. 4U04: bad email
  5. 5U04: age 130 out of range
  6. 61 of 4 users valid

Loading your progress…

Check user records from an API — Python practice · Runtime