You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fecha_1 = datetime.strptime(
fecha1, "%d/%m/%Y"
) # Crea un objeto fecha a partir de un string
fecha_2 = datetime.strptime(fecha2, "%d/%m/%Y")
return print(abs(fecha_2 - fecha_1)) # Resta en valor absoluto de las fechas
dias("1/11/2002", "1/11/2003")
def validar(string: str):
if "/" in string:
partes = string.split(
"/"
) # divide los datos de caracteres en segmentos en función de los separadores.
if 0 < int(partes[0]) <= 31:
if 0 < int(partes[1]) <= 12:
if 1900 < int(partes[2]) <= 2024:
return True
else:
return False
else:
return False
else:
return False
r = True
while r:
fecha = input("Ingrese una fecha con el siguiente formato dd/MM/yyyy: ")
fecha2 = input("Ingrese la segunda fecha con el siguiente formato dd/MM/yyyy:")
if validar(fecha) and validar(fecha2):
dias(fecha, fecha2)
break
else:
print("Formato invalido")
The text was updated successfully, but these errors were encountered:
from datetime import datetime
def dias(fecha1: str, fecha2: str):
dias("1/11/2002", "1/11/2003")
def validar(string: str):
r = True
while r:
The text was updated successfully, but these errors were encountered: