Empty Is Not Nothing

Beginners routinely collapse four distinct ideas into one. They are not the same:

0, a number. A real value that happens to be zero.

"", a string containing zero characters. Still a string.

[], a list/array with no items. Still a collection.

None / null, no value of any kind exists here.

EXAMPLE
loading editor…
YOUR TURN
Your turn → Make four variables of your own: a count of 0, an empty name, an empty shopping list and a missing birthday. Print the type of each.
loading editor…

Syntax has to be exact. Every quote, bracket and parenthesis needs its partner, and in Python the spaces at the start of a line count. One slip and the program won't run; the message will say where.

The practical skill is checking for nothing before you use a value. Both languages have a clean idiom for it.

Checking for absence

PYTHON

if middle_name is None:
    print("No middle name on file")

JAVASCRIPT

if (middleName === null) {
  console.log("No middle name on file");
}
Compare → Python uses the word `is` for identity checks against None, write `is None`, not `== None`. JavaScript uses strict equality against null. Module 14 covers if-statements fully; here you're just meeting the pattern you'll use forever.
EXAMPLE
loading editor…
YOUR TURN
Your turn → Missing data is a fact worth recording honestly. Add a variable for a birth year that nobody documented, and check it.
loading editor…

Syntax has to be exact. Every quote, bracket and parenthesis needs its partner, and in Python the spaces at the start of a line count. One slip and the program won't run; the message will say where.

◈ Graded Challenge

An archive record has a known name, a photo count that is genuinely zero, and an interview that was never recorded. Create name, photo_count, and interview so each value honestly represents its situation.

Name it exactly: name, photo_count, interview

2 visible + 2 hidden
loading editor…

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Practice Test →
← Back