Apr-07-2020, 11:18 AM
(Apr-07-2020, 09:36 AM)deanhystad Wrote: Unpack the list and check if the key value is already in the dictionary.
def check(seq): new_dict = {} for i in seq: (key, value), *rest = i.items() if value in new_dict: print("Numero en double! " + "---->" + value + " Fichier non utilisable!") else: new_dict[value] = dict(rest) return new_dictI don't know what you want to do for duplicated entries. The code above prints your message and excludes the duplicate entry.
If If the list has a number of key "numero" duplicated, it does not create a new dict. New dict is only available when all values of key "numero" are unique.