Unit 2 Task 29: Bus passenger count

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Unit 2 Task 29 - Bus passenger count

← Unit 2 tasks · Solution


The bus starts empty. Each input is an integer:

The passenger count must never go below 0-if more people try to leave than are on board, cap at 0 or ignore the excess (your choice, but explain in a comment).

At the end print final passenger count.

Skills: while, if guarding realistic counts.