-3
リストd1とd2の2つの文字列を比較したい。 d1の文字列がd2と似ている場合は、同様の文字列を返します。リストから作成した2つの文字列の比較
ここに私のコードです:それはSTR1における類似文字列から来^
['learn','learn']
:
d1 = [['learn'],['car']]
d2 = [['learn'],['motor']]
str1 = ', '.join(str(i) for i in d1)
str2 = ', '.join(str(j) for j in d2)
for i in str1:
for j in str2:
if i == j:
print str1, str2
が、出力は次のようになります。
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
['learn'], ['car'] ['learn'], ['motor']
私は出力があることを期待とstr2。
誰でもお手伝いできますか?
試してみてください。 'プリント私は、j' –
私は何を理解していません後になります。あなたは2つのリストの交差点を探していますか?すなわち、両方のリストに存在する要素。 – pookie
彼はそうだと思う。 –