
Bug hunt
The Ferry Fare Fiasco
Because elif stops at the first true branch, the order of
your conditions matters a lot. A wide condition placed first
can "swallow" everything after it.
The Moonwell ferry has these fares:
| Age | Fare |
|---|---|
| under 4 | 0 gold |
| 4 to 11 | 5 gold |
| 12 to 64 | 10 gold |
| 65 and older | 6 gold |
Complaints are pouring in: grandparents are being charged 10 gold! And a sharp-eyed sailor noticed something odd about passengers who are exactly 65.
Assignment
Fix ferry_fare(age) so it returns the right fare for every
age. There are two bugs. Try ferry_fare(70) and
ferry_fare(65) to see them.
Fix ferry_fare(age) so it returns the right fare for every
age. There are two bugs. Try ferry_fare(70) and
ferry_fare(65) to see them.
main.py Python sleeping
Press Run to try your code, then Check to test it.