Discussion Room : IDC101

Unexpected behavior of s.count(substr) when substr = ""

Re: Unexpected behavior of s.count(substr) when substr = ""

by Kapil Paranjape -
Number of replies: 0

You have misunderstood the definition of super.count(sub). It counts the number of occurrences of the sub-string sub in the string super.

There are 6 (count them!) occurrences of the empty string in the string "super".

Try to write the correct program to do what count does.