python - Why does '12345'.count('') return 6 and not 5? -


>>> '12345'.count('') 6 

why happen? if there 5 characters in string, why count function returning 1 more?

also, there more effective way of counting characters in string?

count returns how many times object occurs in list, if count occurrences of '' 6 because empty string @ beginning, end, , in between each letter.

use len function find length of string.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -