-
-
Save parzibyte/64c9c864536b4fee0735ab1b86ec5cb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def burbuja(arreglo): | |
longitud = len(arreglo) | |
for i in range(longitud): | |
for indice_actual in range(longitud - 1): | |
indice_siguiente_elemento = indice_actual + 1 | |
if arreglo[indice_actual]["año"] < arreglo[indice_siguiente_elemento]["año"]: | |
arreglo[indice_siguiente_elemento], arreglo[indice_actual] = arreglo[indice_actual], arreglo[indice_siguiente_elemento] | |
def guardar_años_cronologicamente(): | |
lista = obtener_lista_facturacion() | |
burbuja(lista) | |
with open(NOMBRE_ARCHIVO_ESCRITURA, "w", encoding="utf-8") as archivo: | |
for elemento in lista: | |
año = elemento["año"] | |
total = (elemento["trimestre1"] + elemento["trimestre2"] + | |
elemento["trimestre3"] + elemento["trimestre4"]) | |
archivo.write(f"Año {año} facturación anual de: {total} euros.\n") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment