Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def remover_duplicados(secuencia, funcion_hash = None):
- elementos_iterados = set()
- for elemento in secuencia:
- valor = elemento if funcion_hash is None else funcion_hash(elemento)
- if valor not in elementos_iterados:
- yield valor
- elementos_iterados.add(valor)
- lista_diccionarios = [{'x':2,'y':3} ,{'x':2,'y':5}, {'x':2,'y':3}, {'x':3,'y':5}]
- print(list(remover_duplicados(lista_diccionarios, funcion_hash = lambda d: (d['x'], d['y']))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement