1
sample = ['A$$N','BBBC','$$AA']
リスト内の他のすべての要素とすべての要素を比較する必要があります。したがって、サンプル[0]とサンプル[1]、サンプル[0]とサンプル[2]、サンプル[1]とサンプル[2]を比較してください。 a 比較のペアのいずれかに "$"がある場合、 "$"と対応する要素を削除する必要があります。 例inリスト(Python)内の要素とそれに対応する文字の中の文字を削除するにはどうすればいいですか?
sample[0] and sample[1] Output1 : ['AN','BC']
sample[0] and sample[2] Output2 : ['N', 'A']
sample[1] and sample[2] Output3 : ['BC','AA']
for i in range(len(sample1)):
for j in range(i + 1, len(sample1)):
if i == "$" or j == "$":
#Need to remove "$" and the corresponding element in the other list
#Print the pairs
ありがとう、それは完璧に動作します。私はこのようなコードを理解するのが好きです – Biotechgeek