Objective
Data coming from outside can be invalid. tomllib.loads raises TOMLDecodeError if the TOML text is malformed, and a robust program must catch it.
Instructions
- The first line has the number
nof lines; then come those lines of a TOML document. - If it is valid, show its content as JSON with
json.dumps(data, sort_keys=True)(on one line). Otherwise showInvalid TOML.
3
nombre = "ana"
edad = 30
notas = [7, 9]
{"edad": 30, "nombre": "ana", "notas": [7, 9]}
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise