Quick answer
To repair the pressure sensor, read its live value and test whether it is even. If the reading is already even, keep it. If it is odd, add one. After that, call stabilize() with the corrected number. The cleanest starter check uses modulo 2 in an if/else block.
Working script
p_sensor = get_component("pressure sensor")
p = p_sensor.get_value()
if p % 2 == 0:
fixed = p
else:
fixed = p + 1
p_sensor.stabilize(fixed)
How the odd/even check works
p % 2 gives the remainder after dividing by two. An even number leaves remainder 0; an odd number leaves remainder 1. The starter objective says even readings are valid, while odd readings need to be bumped up by one.
Debug it before you stabilize
If you are still learning conditions, temporarily print the current reading and your branch result. That lets you prove the if/else logic before the objective clears and moves on.
Most common mistakes
- Using
=where the condition needs==. - Forgetting indentation under
iforelse. - Using normal division instead of modulo to test odd/even state.
- Calling the wrong final method. The pressure repair uses
stabilize().