There are 3 dictionaries: inventData , invent101 and invent21 , which I invent21 together, making 1 of them - inventDataAll .
Although the dictionaries are connected, the fact is that the inventData dictionary contains data that is not in invent101 and invent21 . I need the script to print what data it did not find, but this does not happen.
Instead, the "Inventory" + value ['invent'] + "invoice does not appear" appears exactly as many times as the first cycle works, regardless of whether this data is in invent101 and invent21 or not.
I wanted to get help on this.
inventData = {} # 1 словарь # ... inventData.setdefault(index, dict(name=name, serial=serial, invent=invent, produce=produce)) # ... invent101 = {} # 2 словарь # ... invent101.setdefault(index, dict(invent=invent, checked=checked, worked=worked, cost=cost)) # ... invent21 = {} # 3 словарь # ... invent21.setdefault(index, dict(invent=invent, checked=checked, worked=worked, cost=cost)) # ... inventDataAll = {} # Итоговый словарь for key, value in inventData.items(): for key101, value101 in invent101.items(): if value['invent'] == value101['invent']: inventDataAll.setdefault(key, dict(name=value['name'], serial=value['serial'], invent=value['invent'], produce=value['produce'], checked=value101['checked'], worked=value101['worked'], cost=value101['cost'])) elif value['invent'] != value101['invent']: for key21, value21 in invent21.items(): if value['invent'] == value21['invent']: inventDataAll.setdefault(key, dict(name=value['name'], serial=value['serial'], invent=value['invent'], produce=value['produce'], checked=value21['checked'], worked=value21['worked'], cost=value21['cost'])) else: print("Инвентарник" + value['invent'] + "счетах не значится")