recommend("opera") crashes with IndexError: opera has no history, so the ranking is empty and ranking[0] explodes. That's the cold-start case, and the mission's rule is: degrade gracefully AND say so. Fix recommend() to fall back to the global most-popular item, tagged "cold start: global top" — never crash, never fail silently.
The break is on line 14 — but read the whole snippet first.