The lifespan of a cobra can vary depending on the species and other factors such as habitat and diet. In general, cobras can live for several years in the wild, with lifespans ranging from 5 to 20 years. Some species, such as the King Cobra, can live up to 30 years or more in captivity with proper care.