import json def verif_code_article(lst_art): if len(lst_art) == 0: json_data = {"result": "Success", "Missing": None} else: ref_code_art = get_ref_code_art() cnt = 0 missing = [] for i in lst_art: if i not in set(ref_code_art): cnt += 1 missing.append(i) if cnt > 0: print(cnt) json_data = {"result": "Failure", "Missing": missing} else: json_data = {"result": "Success", "Missing": None} return json_data res = verif_code_article(articles) print(len(res)) if len(res) > 1: with open("outputs.json", "w") as json_file: json_file.write(json.dumps(res)) else: with open("outputs.json", "w") as json_file: json_file.write(json.dumps('Problem'))