I want to ask if there is a better way to check the number of characters matches for two different string. For example when I input the word 'succeed' I want to know how many characters does it match the word 'success' at the exact position. In this case, 'succeed' matches 5 out of 7 characters of 'success'. This function is needed to be implemented into a bigger project. Right now I have a proof of concept python code:
word1 = input('Enter word1>')
word2 = input('Enter word2>')
#word1 is being compared to word2
word1_character_list = list(word1)
word2_character_list = list(word2)
matching_word_count = 0
for index in range(0,len(word2)):
if word1_character_list[index] == word2_character_list[index]:
matching_word_count = matching_word_count + 1
print(matching_word_count)
I wonder if there is a simpler and/or shorter way to do it? Or a way that use less variables. Any help will be appreciated.