← Back to challenges

String Match by Two Letters

PythonHardstringsarrayslanguage_fundamentals

Instructions

Create a function that takes two strings, a and b. Return the number of times the two strings contain the same two letters at the same index. The two letters must appear at consecutive indices.

For example, if a = "bboiizz" and b = "bbuiiz", your function should return 3, since the "bb", "ii", and "iz" appear at the same place in both strings.

Examples

str_match_by2char("yytaazz", "yyjaaz") ➞ 3

str_match_by2char("innokodakademija", "ed") ➞ 1

str_match_by2char("", "") ➞ 0
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Check if a String is a Mathematical Expression