Help with a substring length 2 | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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