+ 2

Help with a substring length 2

I was practicing Python and came across this task. I can’t understand why last2(‘axxxaaxx’) Is returning 2 Çan someone explain please? The task: Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so "hixxxhi" yields 1 (we won't count the end substring). last2('hixxhi') → 1 last2('xaxxaxaxx') → 1 last2('axxxaaxx') → 2 https://codingbat.com/prob/p145834

17th Jun 2019, 8:18 PM
wave rider
2 ответов
+ 3
The function should count overlapping occurrences of the substring. aXXxaaxx axXXaaxx
17th Jun 2019, 8:40 PM
Diego
Diego - avatar
+ 4
I got you, thank you Diego
17th Jun 2019, 9:16 PM
wave rider