Question

Python Question!! Given the list of employees defined in the cell below, process the list of...

Python Question!! Given the list of employees defined in the cell below, process the list of dictionaries to create a list of first names.

Join the first names with a comma followed by space to form a single string e.g. Jonathan, Christopher, Isabella, Barbara and print the string.

employees = [
    {
        "email": "jonathan2532.calderon@g.com",
        "employee_id": 101,
        "firstname": "Jonathan",
        "lastname": "Calderon",
        "title": "Mr",
        "work_phone": "(02) 3691 5845"
    },
    {
        "email": "christopher8710.hansen@g.com",
        "employee_id": 102,
        "firstname": "Christopher",
        "lastname": "Hansen",
        "title": "Mr",
        "work_phone": "(02) 5807 8580"
    },
    {
        "email": "isabella4643.dorsey@g.com",
        "employee_id": 103,
        "firstname": "Isabella",
        "lastname": "Dorsey",
        "title": "Mrs",
        "work_phone": "(02) 6375 1060"
    },
    {
        "email": "barbara1937.baker@g.com",
        "employee_id": 104,
        "firstname": "Barbara",
        "lastname": "Baker",
        "title": "Ms",
        "work_phone": "(03) 5729 4873"}]
 
0 0
Add a comment Improve this question Transcribed image text
Answer #1


employees = [
{
"email": "jonathan2532.calderon@g.com",
"employee_id": 101,
"firstname": "Jonathan",
"lastname": "Calderon",
"title": "Mr",
"work_phone": "(02) 3691 5845"
},
{
"email": "christopher8710.hansen@g.com",
"employee_id": 102,
"firstname": "Christopher",
"lastname": "Hansen",
"title": "Mr",
"work_phone": "(02) 5807 8580"
},
{
"email": "isabella4643.dorsey@g.com",
"employee_id": 103,
"firstname": "Isabella",
"lastname": "Dorsey",
"title": "Mrs",
"work_phone": "(02) 6375 1060"
},
{
"email": "barbara1937.baker@g.com",
"employee_id": 104,
"firstname": "Barbara",
"lastname": "Baker",
"title": "Ms",
"work_phone": "(03) 5729 4873"}]


# function required
def processArray(data):
    procStr = ""
    for d in data:
        procStr = procStr+d["firstname"]+" "
    procStr = procStr.strip()
    procStr = procStr.replace(" ",", ")
    return procStr
#using the function
print(processArray(employees))

Add a comment
Know the answer?
Add Answer to:
Python Question!! Given the list of employees defined in the cell below, process the list of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (8Python Question!!! Given the list of employees defined in the cell below, process the list of...

    (8Python Question!!! Given the list of employees defined in the cell below, process the list of dictionaries to create a list of employee names formatted as title firstname lastname e.g. Mr Jonathan Calderon, etc Hint: This problem can be solved in one line using map() with a lambda function employees = [ { "email": "jonathan2532.calderon@g.com", "employee_id": 101, "firstname": "Jonathan", "lastname": "Calderon", "title": "Mr", "work_phone": "(02) 3691 5845" }, { "email": "christopher8710.hansen@g.com", "employee_id": 102, "firstname": "Christopher", "lastname": "Hansen", "title": "Mr", "work_phone":...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT