CSV and JSON files · 12 / 15 Exercise Medium

Creating a JSON

Objective

Create a Python program that builds a dictionary and converts it into JSON text with json.dumps.

Instructions

  • Read a name, an age (integer) and a line that is 1 if the person is a student or 0 if not.
  • Create a dictionary with the keys name, age and student, in that order. The value of student must be a boolean (True or False), not a text.
  • Show the dictionary converted to JSON with json.dumps(data, ensure_ascii=False), so that accented letters are not escaped.
Input
Ana
30
1
Output
{"name": "Ana", "age": 30, "student": true}

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise