Given an array of users, write a function, namesAndRoles that returns all of user's names and roles in a string with each value labeled.For example: const users = [ { name: 'Homer', role: 'Clerk', dob: '12/02/1988', admin: false },{ name: 'Lisa', role: 'Staff', dob: '01/30/1965', admin: false },{ name: 'Marge', role: 'Associate', dob: '09/10/1980', admin: true } ] namesAndRoles(users) // Name: Homer // Role: Clerk // Name: Lisa // Role: Staff // Name: Marge // Role: Associatefunction namesAndRoles(users) { return users } namesAndRoles(users)

Respuesta :

Answer:

def namesAndRoles(users):

   for user in users:

       return f"{user[name]}, {user[role]}"

Explanation:

The python program gets the list of dictionaries of the users in a company and returns the user names and their roles. The code is defined as a function and is executed when the function is called.