← Back to challenges

Get Notes Distribution

PythonHardarraysobjects

Instructions

Create a function that takes a list of students and returns a dictionary representing their notes distribution. Keep in mind that invalid notes should not be counted in the distribution. Valid notes are: 1, 2, 3, 4, 5

Example

get_notes_distribution([
  {
    "name": "Steve",
    "notes": [5, 5, 3, -1, 6]
  },
  {
    "name": "John",
    "notes": [3, 2, 5, 0, -3]
  }
] ➞ {
  5: 3,
  3: 2,
  2: 1
})

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.