I'm trying to compare the characters from 2 separate strings, the idea is that i will return a value corresponding to how many characters the strings both share. for example, if string one was 'mouse' and string 2 was 'house'. They would share 4/5 characters. its important to note that they only share a character if it is in the same 'index position'
def compareWords(word1, word2):
result = 0
if word1[0] in word2[0]:
result += 1
if word1[1] in word2[1]:
result += 1
if word1[2] in word2[2]:
result += 1
if word1[3] in word2[3]:
result += 1
if word1[4] in word2[4]:
result += 1
if word1[5] in word2[5]:
result += 1
print result, '/5'