2

This is my code:

a = 'BANANAAAS'
sub='AA'

print(a.count(sub))

Why does it not print 2 as an answer since the substring appears 2 times? The first one begining in a[5] and the other begining in a[6].

This was a part of a larger problem where I have to generate and count all the substring in a string depending if it begins with a vowel or not.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135

0 Answers0