In searching for hidden objects, infants younger than 12 months frequently commit the classic A-not-B error, 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). The question is why they fail to make the switch and perseverate at the first location. While these errors have often been attributed to cognitive limitations or stages of neurological development, we propose that they are consistent with the early stages of learning. We present a context-learning model of A-not-B search, in which learning to adopt the appropriate search strategy involves attending to appropriate contextual cues. We then present the findings of an eye-tracking experiment with 9 month-olds that behaviorally supports the predictions of our learning model.