Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Reading JSON files
7. Nulls in JSON
Summary and Review

Instruction

In JSON, some values can be null. Suppose we have the following JSON file:

{
  "first_name": "Emma",
  "last_name": "Jones",
  "age": 43,
  "is_manager": null
}

When we load the file into Python, we get:

{
  'first_name': 'Emma',
  'last_name': 'Jones',
  'age': 43,
  'is_manager': None
}

The JSON value null is loaded into the Python as None.

Exercise

Load the file named customer2.json into memory as customer2, and check if we have information about the status of our client. If the VIP status is None, print 'Missing data'.

From now on, you don't have to import the json package yourself – we've already done it for you.

Stuck? Here's a hint!

Use the following code:

if customer2["is_VIP"] is None: