Ball pythons can live up to 30 years in captivity if given proper care and a healthy environment, although the average lifespan is around 20-25 years.