← Questions

Train fare calculator with a weekend cap

0
AmazonCodingLast asked Aug 2026

A train line runs through stations G, U, H, K and I in that order. Each hop between neighbouring stations costs 1, so a trip costs the number of hops it covers (G to I costs 4). Build it in three steps: a fare function for one trip, then let the list of stations change, then cap what a rider pays over a weekend.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding