← Back to challenges

Names, Ages and Occupations

PythonHardhigher_order_functionsobjects

Instructions

Write a function that maps a string into a dictionary of name, string, and occupation pairs.

Examples

organize("Jameel Saeb, 15, CEO of facebook") ➞ {
  "name": "Jameel Saeb",
  "age": 15,
  "occupation": "CEO of facebook"
}

organize("John Mayer, 41, Singer") ➞ {
  "name": "John Mayer",
  "age": 41,
  "occupation": "Singer"
}

organize("") ➞ {}

Notes

  • Return an empty dictionary if given an empty string.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Moving Partition