python function count characters in string