Solved Stage 2 — ValueError from an f-string? MAMateoGOP 17 Sep, 09:35 I didn't know f-strings could throw ValueError. The line has curly braces from the JSON.
TOTomBecker17 Sep, 15:02 Solutionreplies: 2Inside an f-string, { starts a placeholder. Python tries to read "status": ... as an expression with a format spec and fails. Literal braces need to be doubled — that's the hint for this stage.
SASamPrice17 Sep, 21:34For real JSON, build a dict and use json.dumps() instead of assembling text by hand. The "JSON out" challenge covers it.
Comments 4
Join the discussion CommentAlready have an account? Log in
Inside an f-string,
{starts a placeholder. Python tries to read"status": ...as an expression with a format spec and fails. Literal braces need to be doubled — that's the hint for this stage.Doubled braces, and now it prints the JSON. Ugly but works.
Agreed, but this is a good lesson in why hand-made JSON is fragile.
For real JSON, build a dict and use
json.dumps()instead of assembling text by hand. The "JSON out" challenge covers it.