In searching for hidden objects, infants younger than 12 months frequently commit A-not-B errors, in which they successfully search for an object in one location (A) and then fail to search for it when it is conspicuously hidden in a new location (B). Why do they fail to make the switch and perseverate at the first location? Although these errors have often been attributed to cognitive and conceptual limitations, we suggest that the answer is far more basic: in order to search successfully, children must first learn to do so. In what follows, we present an error-driven learning account of A-not-B search which suggests that failing to make the switch is an essential part of learning the appropriate searching cues and contextual search strategies. We elaborate the findings of an eye-tracking experiment with 9 month-olds that behaviorally confirms the predictions of our learning model.