Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: A Program that prints the numbers from 1 to 100 Date: Mon, 16 Nov 2015 23:35:37 +1100 Lines: 25 Message-ID: References: <85eea326-406d-4454-8c3a-859f1e464cfc@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 5QtPktih+1UAsfZVwXRdcA8rWFno2mQj7L+JxGWSfh/g== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'received:209.85.223': 0.03; 'sufficient': 0.05; 'bug.': 0.07; 'cc:addr:python-list': 0.09; 'get.': 0.09; 'shame': 0.09; 'bug': 0.10; 'python': 0.10; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:" 100': 0.16; 'skip:n 50': 0.16; 'wrote:': 0.16; 'debugging': 0.18; 'detect': 0.18; 'version.': 0.18; 'project,': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'code.': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'this.': 0.28; 'subject:numbers': 0.29; 'subject:that': 0.29; 'code': 0.30; 'version,': 0.30; 'another': 0.32; 'help,': 0.32; 'received:google.com': 0.35; 'nov': 0.35; 'submitting': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'subject:from': 0.39; 'subject:the': 0.39; 'your': 0.60; 'chrisa': 0.84; 'malicious': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=oeqtQSX5/Lvdk9Wqk9BqZKXEU4p2qf8ETMajZ42NSBA=; b=jl+C+wPsAPDbDiCDobExY1GEP+TtVVBbc2DOXSNd2BLJWrp3d3nt32ZEDCMZbC4XG2 H4nSFyz7Jwml244sYqnbZA3AdDTVrmsL9nsulvc0Cj6gENmAwjqcrNtLQXes/bJNvOPv 8B/ihSjjVtDY0FCrUCwzu3VEbeQlPycHaE/ZdMSuBcsbQTLaJ7eciK3QKfETfWU92lKx PwI5Dfx8gEGV7pZ2V0+y3FQrLCeL4aK6YmOLPLcd0atgDSgDl593zsDEEf/DlRm1cV+j sOYZI9QnjEQbN8m1G1lPo0KyyfFSfm0DuVrxLHaPHL6BVpFdubmOJIyksbztgzUtakCd v5nA== X-Received: by 10.107.16.84 with SMTP id y81mr30100562ioi.19.1447677337644; Mon, 16 Nov 2015 04:35:37 -0800 (PST) In-Reply-To: <85eea326-406d-4454-8c3a-859f1e464cfc@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98876 On Mon, Nov 16, 2015 at 10:57 PM, wrote: > This would help, but try to write on your own to improve, else you cant make this going long.... > Here's another version, but with a deliberate bug in it. You may use this code if and only if your comprehension is sufficient to detect and correct that bug. next(filter(None,(print(next(filter(None,reversed(x)))) for x in enumerate(itertools.islice(itertools.cycle(("Fizzbuzz",0,"","Fizz",not "Fuzz","Buzz","Fizz",(),bytes(),"Fizz","Buzz",{},"Fizz",False,globals().get(math.pi))),1,101)))),None) Actually... you know what, I think debugging THAT is a malicious prank to pull on an experienced Python programmer; plus, if you're caught submitting that for your project, you deserve all the shame you get. Trust me, this is NOT good code. Here's the corrected version. It works, but you do not want to use this. next(filter(None,(print(next(filter(None,reversed(x)))) for x in itertools.islice(enumerate(itertools.cycle(("Fizzbuzz",0,"","Fizz",not "Fuzz","Buzz","Fizz",(),bytes(),"Fizz","Buzz",{},"Fizz",False,globals().get(math.pi)))),1,101))),None) Enjoy! ChrisA