Cognitive flexibility enables animals to alter their behaviour and respond appropriately to environmental changes. Such flexibility is important in urban settings where environmental changes occur rapidly and continually. We studied whether free-living, urban-dwelling yellow mongooses, Cynictis penicillata, in South Africa, are cognitively flexible in reversal learning and attention task experiments (n = 10). Reversal learning was conducted using two puzzle boxes that were distinct visually and spatially, each containing a preferred or non-preferred food type. Once mongooses learned which box contained the preferred food type, the food types were reversed. The mongooses successfully unlearned their previously learned response in favour of learning a new response, possibly through a win-stay, lose-shift strategy. Attention task experiments were conducted using one puzzle box surrounded by zero, one, two or three objects, introducing various levels of distraction while solving the task. The mongooses were distracted by two and three distractions but were able to solve the task despite the distractions by splitting their attention between the puzzle box task and remaining vigilant. However, those exposed to human residents more often were more vigilant. We provide the first evidence of cognitive flexibility in urban yellow mongooses, which enables them to modify their behaviour to urban environments.