why "g".count('')==2 ?

Terry Reedy tjreedy at udel.edu
Sat Mar 11 18:15:06 CET 2006


For the same reason as
>>> "".count("")
1
>>> "ab".count("")
3

This is counting slice positions, which is one more that the length of the 
string.






More information about the Python-list mailing list