On Tue, 26 Aug 2008 17:04:19 -0700, tdmj wrote: > On Aug 26, 5:49 pm, [EMAIL PROTECTED] wrote: >> I have a list that starts with zeros, has sporadic data, and then has >> good data. I define the point at which the data turns good to be the >> first index with a non-zero entry that is followed by at least 4 >> consecutive non-zero data items (i.e. a week's worth of non-zero data). >> For example, if my list is [0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], I >> would define the point at which data turns good to be 4 (1 followed by >> 2, 3, 4, 5).
... > With regular expressions: Good grief. If you're suggesting that as a serious proposal, and not just to prove it can be done, that's surely an example of "when all you have is a hammer, everything looks like a nail" thinking. In this particular case, your regex "solution" gives the wrong result, indicating that you didn't test your code before posting. Hint: re.search(r'[1-9]{5, }', "123456") returns None. The obvious fix for that specific bug is to use r'[1-9]{5,5}', but even that will fail. Hint: what happens if an item has more than one digit? Before posting another regex solution, make sure it does the right thing with this: [0, 0, 101, 0, 1002, 203, 3050, 4105, 5110, 623, 777] -- Steven -- http://mail.python.org/mailman/listinfo/python-list