Stefan Behnel wrote:
Wolfgang Rohdewald wrote:I want to match a string only if a word (C1 in this example) appears at most once in it.def match(s): if s.count("C1") > 1: return None return s If this doesn't fit your requirements, you may want to provide some more details.
That will return a false value if s is the empty string. How about: def match(s): return s.count("C1") <= 1 -- HansM -- http://mail.python.org/mailman/listinfo/python-list