次の2つの配列があります.invalid_id_arrの要素がvalid_id_arrに存在するかどうかを確認しようとしていますが、存在しない場合はdiff配列を形成し['id123', 'id124', 'id125', 'id126', 'id789', 'id666']
ます["id789","id666"]
ここで何が間違っているのかという出力
tag_file= {}
tag_file['invalid_id_arr']=["id123-3431","id124-4341","id125-4341","id126-1w","id789-123","id666"]
tag_file['valid_id_arr']=["id123-12345","id124-1122","id125-13232","id126-12332","id1new","idagain"]
diff = [ele.split('-')[0] for ele in tag_file['invalid_id_arr'] if str(ele.split('-')[0]) not in tag_file['valid_id_arr']]
現在の出力:
['id123', 'id124', 'id125', 'id126', 'id789', 'id666']
予想される出力:
["id789","id666"]