Checking your account

You can read the lesson while its saved answers and constructions load. Learning controls will open once that work is ready.

Python Validation and Error Handling

Save a Batch without Leaving Half an Update

Coding challenges

BOTIE

Return one ready-or-reject word per incoming reading. For [4, 8], return ["ready", "ready"].
Ready to test
0 passed · 0 failed · 3 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

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.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Return one ready-or-reject word per incoming reading. For [4, 8], return ["ready", "ready"].

The saved readings are [2]. Adding [4, 8] should produce [2, 4, 8]. A request containing zero, a negative number or text must leave the saved readings unchanged.

Inspect the component calculation
Check each reading(
  Incoming readings: Incoming batch
  Accept: positive numbers
)
Examples and results
Incoming batch
  1. 04
  2. 18
Required result
  1. 0ready
  2. 1ready
Incoming batch
  1. 07
  2. 1eight
Required result
  1. 0ready
  2. 1reject
Incoming batch
[]
Required result
[]
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

This shows the resulting list without changing the source. It does not save a file or provide a database transaction. 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.

A Later Request Contains Two Bad Readings

This check uses the pieces from “Check before Appending”.

BOTIE

The saved list is [9, 10]. The incoming request is [7, true, 3, -4]. The saving operation still requires every incoming reading to be a positive number.
Saved readings
  1. 09
  2. 110
Incoming batch
  1. 07
  2. 1true
  3. 23
  4. 3-4

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.

What should remain in the saved list if only the final incoming value fails?

Check the whole request before changing the saved data.

This shows the resulting list without changing the source. It does not save a file or provide a database transaction.

Continue the coursePydantic Models and Optional Fields →
← Composition and Interchangeable Components