promptdojo_
Checkpoint

One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.

Last one. Cursor wrote a function get_price that pulls the "price" field out of an item dict and converts it to a float. Right now it crashes on three different inputs:

  • missing "price" key → KeyError
  • empty string for the price → ValueError
  • the dict is NoneAttributeError from the .get call

Rewrite the function so it returns 0.0 for any of those cases, and returns the parsed float when the value is valid. The script should print:

29.99
0.0
0.0
0.0

this step needs the editor

on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.

open this same url on a laptop to keep going today.