← Back to challenges

Assign Person to Occupation

PythonMediumdata_structures

Instructions

You have two lists. One shows the names of the people names, while the other shows their occupation jobs. Your task is to create a dictionary displaying each person to their respective occupation.

PersonJob
AnnieTeacher
StevenEngineer
LisaDoctor
OsmanCashier

Example

names = ["Dennis", "Vera", "Mabel", "Annette", "Sussan"]
jobs = ["Butcher", "Programmer", "Doctor", "Teacher", "Lecturer"]

assign_person_to_job(names, jobs) ➞ {
  "Dennis": "Butcher",
  "Vera": "Programmer",
  "Mabel": "Doctor",
  "Annette": "Teacher",
  "Sussan": "Lecturer"
}

Notes

  • The two lists have the same length.
  • The index of a name in the names list is the same as the index of the person's job in the jobs list, as shown in the table above.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Simple Letters