bugger.
All challenges/Pythoneasythe-counts-that-crash-the-import-v1
THE INVESTIGATION

The counts that crash the import

An importer skips malformed text but crashes on another kind of invalid count.

CollectionsStateRegression testing

What’s going wrong

A batch count importer should omit invalid values without losing later valid records.

Input is a JSON array of values, at most 200. Apply Python int(value) semantics to each value; preserve successful integers in order, including zero and false converted to zero. Omit values for which conversion raises ValueError or TypeError. Values are ordinary JSON, with finite numbers only; floats truncate toward zero. Print one compact JSON array. Empty input prints []. Do not turn invalid values into zero or stop the batch at the first bad record.

Expected behavior

Partition input failures by cause while preserving valid falsey results.

Reproduction

01 Null between valid counts
["4",null,"bad","0"]
[4,0]
02 Ordinary counts
["2","-3",7]
[2,-3,7]
03 Text conversion failure
["7","bad","8"]
[7,8]

Before you begin

  • Python lists and dictionaries

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.