あなたのソリューションは、次のとおりです。
lst1=[['hey','jude' ,'fox'],['how','you','do']]
lst2=[['hey','paul'],['how','do']]
new_list=[]
for item in lst1:
for item_1 in lst2:
if isinstance(item_1,list):
for sub_item in item_1:
if sub_item in item:
if len(sub_item)>=1:
if len(item)>len(item_1):
if item not in new_list:
new_list.append(item)
elif len(item_1)>len(item):
if item_1 not in new_list:
new_list.append(item_1)
if len(sub_item)<2:
if sub_item not in new_list:
new_list.append(sub_item)
new_list.append(item)
print([j for i,j in enumerate(new_list) if j not in new_list[:i]])
P.S:あなたは 「より大きいか1に等しい言葉」によって何を意味するか、混乱と疑問を述べましたあなたは言葉の長さや言葉のマッチングを意味しますか?私は単語のlenを仮定した。
テスト:あなたのリストを持つ
:
出力:
[['hey', 'jude', 'fox'], ['how', 'you', 'do']]
リスト1は、その後comman未満2 lenの手紙を持っている:
lst1=[['hey','jude' ,'fox'],['how','you','do'],["wow"],["wllla","wlahi","aasma"],["h","i","j"]]
lst2=[['hey','paul'],['how','do'],["wllla"],["h"]]
を
出力:
[['hey', 'jude', 'fox'], ['how', 'you', 'do'], ['wllla', 'wlahi', 'aasma'], ['h', 'i', 'j'], 'h']
第二のリストは、両方で一致する最大の共通リストの言葉があります:あなたは、ネスト休憩にロジックを避けたい場合は
[['hey', 'jude', 'fox'], ['how', 'you', 'do'], ['wllla', 'wlahi', 'aasma'], ['h', 'i', 'j'], 'h', ['abc', 'def', 'ghi']]
:
lst1=[['hey','jude' ,'fox'],['how','you','do'],["wow"],["wllla","wlahi","aasma"],["h","i","j"],["abc","def"]]
lst2=[['hey','paul'],['how','do'],["wllla"],["h"],["abc","def","ghi"]]
出力を入れ子にする機能を に減らします。
希望の出力を表示してください。 –
何を試しましたか? [最小限の完全かつ検証可能なサンプルを作成する方法](https://stackoverflow.com/help/mcve)を参照してください。 –