Answer:
Check the explanation
Step-by-step explanation:
def same_char_same_pos(s1,s2):
if len(s1)==0 or len(s2)==0:
return 0
else:
if s1[0]==s2[0]:
return 1+same_char_same_pos(s1[1:],s2[1:])
else:
return same_char_same_pos(s1[1:], s2[1:])
# Testing
print(same_char_same_pos("cat","bat"))
print(same_char_same_pos("cat","acat"))
Kindly check the output in the image below: