私はプログラミングにまったく慣れていないので、Stackoverflow で 2 つのリストの文字列の一致に関する Q & A をいくつか読みましたが、この正確なタスクに役立つものは見つかりませんでした。
次のようにリストする必要があります。
list1 = ["INTP", "ESFJ", "ENTJ"]
list2 = ["ENTP", "ESFP", "ISTJ"]
次のように、各単語の各文字を反復処理し、行われたすべての比較、リスト内のすべての単語の一致する文字の総数、および一致する文字のすべての部分を保存します。
total_letters_compared = 12
total_correct_matches = 8
first_letter_pair_matches = 1
second_letter_pair_matches = 2
third_letter_pair_matches = 3
fourth_letter_pair_matches = 2
両方のリストの特定のインデックス [i] で比較を行う方法がわからないので、どうにかして変数に一致を格納できます。これまでに思いついたのは次のとおりです。
total = 0
total_letters_compared = 0
total_correct_matches = 0
first_letter_pair_matches = 0
second_letter_pair_matches = 0
third_letter_pair_matches = 0
fourth_letter_pair_matches = 0
for combination in list2:
for letter in combination:
total_letters_compared = total_letters_compared + 1
if list2letter == list1.ltter:
total_correct_matches = total_correct_matches + 1
# here I´d like to keep track of which letter-pair is compared and
# add 1 to the correct variable or continue to the next letter-pair