Why are str.count(”) and len(str) giving different outputs when used on an empty string?
str.count() counts non-overlapping occurrences of the substring: Return the number of non-overlapping occurrences of substring sub. There is exactly one such place where the substring ” occurs in the string ”: right at the start. So the count should return 1. Generally speaking, the empty string will match at all positions in a given string, … Read more