Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since the "xx", "aa", and "az" substrings appear in the same place in both strings.

string_match('xxcaazz', 'xxbaaz') ? 3

string_match('abc', 'abc') ? 2

string_match('abc', 'axc') ? 0

Here is my code that returns a "string index out of range" error...

`def string_match(a, b):`

min = 0

count = 0

if len(a) >= len(b):

min = len(a)

else:

min = len(b)

for i in range(min-1):

if (a + a[i+1]) == (b + b[i+1]):

count += 1

return count

Here is the modified code that works...

How are the 2 "if" statements not equal? Why is the one in the first example wrong?

Here is the modified code that works...

`def string_match(a, b):`

lesser = 0

count = 0

if len(a) >= len(b):

lesser = len(a)

else:

lesser = len(b)

for i in range(lesser-1):

if a[i:i+2] == b[i:i+2]:

count += 1

return count

How are the 2 "if" statements not equal? Why is the one in the first example wrong?