count digits function in python