Array.count() function

a = “aaaabbcca”
print(a.count(“aaa”)
shouldn’t the output pe 2 because we have two such substrings aaa from start and then aaa from 2nd a
but why it is print 1 as output can u explain

hey @ChiteshBansal ,
its because of the functioning of the count function.
after getting the first occurence it updates the pointer to next index after the substring.
to deal with this you need to work in a bit different way.

Then what is point of this function then

this function basically lacks at the point when the substrings are overlapped with each other.
So , you can use it in the case when this overlapping is not there , and those times it will work fine.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.