20-08-2009 o 13:01:29 Neal Becker <ndbeck...@gmail.com> wrote:
I meant #occurrences of characters from the set A in string B
But: 1) separately for each element of A? (see Simon's sollution with defaultdict) 2) or total number of all occurrences of elements of A? (see below) 20-08-2009 o 14:05:12 Peter Otten <__pete...@web.de> wrote:
identity = "".join(map(chr, range(256))) n = len(b) - len(b.translate(identity, a))
Nice, though I'd prefer Simon's sollution: a = set(a) n = sum(item in a for item in b) Regards, *j -- Jan Kaliszewski (zuo) <z...@chopin.edu.pl> -- http://mail.python.org/mailman/listinfo/python-list