In article <mailman.2948.1247229186.8015.python-l...@python.org>,
Jean-Michel Pichavant  <jeanmic...@sequans.com> 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 (a...@pythoncraft.com)           <*>         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

Reply via email to