count how many characters in the same position are eqial in both strings code example
Example 1: count how many characters in the same position are eqial in both strings
sum(1 if c1 == c2 else 0 for c1, c2 in zip(string1, string2))
Example 2: count how many characters in the same position are eqial in both strings
sum(c1 == c2 for c1, c2 in zip(string1, string2))