Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'element': 0.07; 'list?': 0.07; 'builtin': 0.09; 'meaningful': 0.09; 'tmp': 0.09; 'subject:Help': 0.11; 'blocks': 0.16; 'prev': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'meant': 0.20; 'input': 0.22; 'subject:Code': 0.24; 'looks': 0.24; 'pass': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; 'something': 0.35; 'received:google.com': 0.35; 'keyword': 0.36; 'next': 0.36; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'happen': 0.63; 'more': 0.64; 'anything.': 0.68; 'jul': 0.74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=pfEIL4MmI8IZ1U63urE0myoWTj30Vzha4nAgYL6oP6k=; b=QlqZ9dxD0BYQ6v/sVmJEZa3QYRp2nyXMJ0ExrynDORtYB3lzCcEbApRm8OFvsziaRC ADf7/AqzluKpw8k5piyP38FKs15ibL9saroLpnfDCv/r6Fh14Nh2HmE5eGb7lIpY6evM VYVDGR69HOfEvdCXVtL+qdZzzDj6magDwdGJay9z2uCAeA5mmW9aVh8pgBIvxEmxkLd2 isEJCXiWey2oWm5cW7YCeJsSsaV/imte3FfHLt6NqoUNBIvbQd7Yq24roWrJajfmESim dh40qzwBwqfm/3QrXt6HSrAJVVphmLRshRkyMUZ8M6nl+RsrjCzR/N+D2JOE73TbBN+m 1DEw== X-Received: by 10.69.30.74 with SMTP id kc10mr16936089pbd.111.1404929841270; Wed, 09 Jul 2014 11:17:21 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> References: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> From: Ian Kelly Date: Wed, 9 Jul 2014 12:16:41 -0600 Subject: Re: Help me write better Code To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404929844 news.xs4all.nl 2845 [2001:888:2000:d::a6]:54017 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74270 On Wed, Jul 9, 2014 at 8:27 AM, sssdevelop wrote: > prev = 0 > blocks = [] > tmp = [] > last = 0 > for element in a: > if prev == 0: Is 0 allowed to be in the input list? What would happen if it were? > next This line doesn't do anything. It looks up the builtin function named next and then does nothing with it. I suspect you meant to use the keyword 'continue' here. > if tmp: > pass > else: > tmp.append(prev) if not tmp: tmp.append(prev) Also, give tmp a more meaningful name. Call it "current_block" or something descriptive like that.