In article <[email protected]>,
Jean-Michel Pichavant <[email protected]> wrote:
>
>You could also verify there are at least N different characters used in
>the sentence:
>
>N = 5 # must contains at least 5 different characters
>record = []
>for c in s:
> if c not in record:
> record += [c]
>if len(record) >= N:
> print "at least %s different characters" % N
Much simpler and *way* more efficient with a set:
if len(set(s)) < N:
print "Must have at least %s different characters" % N
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/
"as long as we like the same operating system, things are cool." --piranha
--
http://mail.python.org/mailman/listinfo/python-list