runtime
164 / 500
question 164 Nested Data Structures · easy

Is this earthquake record usable?

Before loading a feed into a map, a data team rejects GeoJSON features that can't be drawn or ranked. Report every problem a feature has, so the feed's owner can fix them all at once.

Functionfeature_problems(feature)
Checks, in this order"no id" when id is missing or None; "no magnitude" when properties or its mag is missing or None; "bad coordinates" when geometry or its coordinates is missing, or the list doesn't hold exactly 3 values
Returnsa list of the problem texts that apply, in the order above; [] for a usable feature
Examples
callfeature_problems({'type': 'Feature', 'properties': {'mag': None, 'place': 'Southern Alaska'}, 'geometry': {'type': 'Point', 'coordinates': [-147.2371, 61.4029]}})returns['no id', 'no magnitude', 'bad coordinates']
callfeature_problems({'type': 'Feature', 'id': 'us6000pw77', 'properties': {'mag': 4.7, 'place': 'Arctic Ocean'}, 'geometry': {'type': 'Point', 'coordinates': [-107.5679, 80.7069, 10]}})returns[]
callfeature_problems({'type': 'Feature', 'id': 'ak0252r9gt13', 'properties': {'mag': None, 'place': 'Southern Alaska'}, 'geometry': {'type': 'Point', 'coordinates': [-147.2371, 61.4029, 9.6]}})returns['no magnitude']

Loading your progress…

Is this earthquake record usable? — Python practice · Runtime