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

Terry Reedy tjreedy at udel.edu
Sat Mar 11 12:15:06 EST 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