Given a GET API that returns a JSON response for 100 customers, write code to manipulate it and map it to the required response shape.
Asked in the Coding stage.
Implement map_customers(payload). The input is a dictionary containing a customers array. Each customer has id, firstName, lastName, email, and an optional nested address.city. Return a dictionary with a customers array containing objects with id, name, email, and city. Preserve input order, construct name from the first and last names, and use None when address or city is absent.
id, firstName, lastName, and email.address and address.city may be absent.def map_customers(payload):