Volver
Ctrl+Space
◑
Copiar
Descargar
Restaurar
Ejecutar
Ctrl+Enter
# Listas en Python - Ejemplo 4: Gestor de tareas # ================================================= tareas = [] def agregar(descripcion): tareas.append({"descripcion": descripcion, "hecha": False}) def completar(indice): if 0 <= indice < len(tareas): tareas[indice]["hecha"] = True def mostrar(): print("\n" + "=" * 35) print(" LISTA DE TAREAS") print("=" * 35) if not tareas: print(" No hay tareas todavía.") for i, t in enumerate(tareas): estado = "✅" if t["hecha"] else "⬜" print(f" {estado} {i + 1}. {t['descripcion']}") print("-" * 35) hechas = sum(1 for t in tareas if t["hecha"]) pendientes = len(tareas) - hechas print(f" ✅ {hechas} completada(s) | ⬜ {pendientes} pendiente(s)") print("=" * 35) # Agregar tareas agregar("Estudiar Python") agregar("Hacer ejercicio") agregar("Leer un libro") agregar("Practicar con el editor") # Completar algunas completar(0) completar(2) # Mostrar mostrar() # Filtrar solo pendientes pendientes = [t["descripcion"] for t in tareas if not t["hecha"]] print(f"\nPendientes: {pendientes}")