[Tutor] need help with python for counter

शंतनू shantanoo at gmail.com
Wed Dec 19 08:08:28 CET 2012


On 19/12/12 5:12 PM, Mitya Sirenef wrote:
> You can also do:
>
> count = sum(i==digit for i in number)
>
> I think this is very clear and short..

Another...

import re
count = len(re.findall(digit, number))

-- 
shantanoo


More information about the Tutor mailing list