Python Validation and Error Handling
Read Counts and Point Out the Bad Fields
BOTIE
Examples, experiments and workspace controls
Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.
Try your own inputs
Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.
Context for this challenge
Return one item per field: numbers for readable decimal text, unchanged text for fields that cannot be read.
The import contains ["8", "3", "5"]. Read them as [8, 3, 5] and report no rejected fields. A later import can contain unreadable text or a negative count. Keep usable counts and identify the original positions needing correction.
Inspect the component calculation
Read whole numbers( Count fields as text: Count fields as text )
Examples and results
- Count fields as text
- 0"8"
- 1"3"
- 2"5"
- Required result
- 08
- 13
- 25
- Count fields as text
- 0"8"
- 1unknown
- 2"5"
- Required result
- 08
- 1unknown
- 25
- Count fields as text
- 0bad
- 1"0"
- 2later
- 3"4"
- Required result
- 0bad
- 10
- 2later
- 34
Try a fresh construction
This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.
Stuck? Inspect a worked construction
The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.
Assumptions and test precision
The local parser accepts small decimal whole-number text. The Python exercises use int() and actual exceptions; this workshop makes their accepted and rejected paths visible. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.
Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.
The Invalid Fields Move
This check uses the pieces from “Keep the Fields in Order”.
BOTIE
- Count fields as text
- 0later
- 1"0"
- 2"9"
- 3missing
Saving your prediction runs your current construction on these inputs and checks the earlier examples too.
Build a construction in the workspace above first. This case will test those pieces.
Why must positions refer to the original fields rather than the shorter accepted list?
Keep an error attached to the data that caused it.
The local parser accepts small decimal whole-number text. The Python exercises use int() and actual exceptions; this workshop makes their accepted and rejected paths visible.