In [1]:
fecha = input("Ingrese fecha a verificar: ")


Ingrese fecha a verificar: 29/02/2004

In [2]:
type(fecha)


Out[2]:
str

In [3]:
valores = fecha.split("/")

In [4]:
valores


Out[4]:
['29', '02', '2004']

In [5]:
type(valores)


Out[5]:
list

In [6]:
año = int(valores[2])

In [7]:
print(año)


2004

In [8]:
mes = int(valores[1])

In [9]:
dia = int(valores[0])

In [14]:
if mes <= 0 or mes > 12:
    print("El mes es invalido")
else:
    maxdia = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    maximo = maxdia[mes]
    if mes == 2 and año%4 == 0:
        # a excepcion de los años 00 pero que no sea divisible por 400, i.e. 2100 no es bisiesto, pero 2000 si.
        maximo += 1
    if dia <= 0 or dia > maximo:
        print("El dia es invalido")
    else:
        print("La fecha",fecha,"es correcta")


La fecha 29/02/2004 es correcta

In [ ]:


In [ ]: