Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98876
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: A Program that prints the numbers from 1 to 100 |
| Date | 2015-11-16 23:35 +1100 |
| Message-ID | <mailman.357.1447677345.16136.python-list@python.org> (permalink) |
| References | <ddada022-49a4-418e-85a1-45cd6da015f7@googlegroups.com> <85eea326-406d-4454-8c3a-859f1e464cfc@googlegroups.com> |
On Mon, Nov 16, 2015 at 10:57 PM, <harirammanohar159@gmail.com> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A Program that prints the numbers from 1 to 100 Cai Gengyang <gengyangcai@gmail.com> - 2015-11-14 09:34 -0800
Re: A Program that prints the numbers from 1 to 100 Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-14 12:49 -0500
Re: A Program that prints the numbers from 1 to 100 BartC <bc@freeuk.com> - 2015-11-14 18:18 +0000
Re: A Program that prints the numbers from 1 to 100 Ammammata <ammammata@tiscalinet.it> - 2015-11-16 11:12 +0000
Re: A Program that prints the numbers from 1 to 100 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-14 18:25 +0000
Re: A Program that prints the numbers from 1 to 100 Steven D'Aprano <steve@pearwood.info> - 2015-11-15 12:39 +1100
Re: A Program that prints the numbers from 1 to 100 harirammanohar159@gmail.com - 2015-11-16 03:57 -0800
Re: A Program that prints the numbers from 1 to 100 Chris Angelico <rosuav@gmail.com> - 2015-11-16 23:35 +1100
Re: A Program that prints the numbers from 1 to 100 Jussi Piitulainen <harvesting@is.invalid> - 2015-11-16 15:39 +0200
Re: A Program that prints the numbers from 1 to 100 Chris Angelico <rosuav@gmail.com> - 2015-11-17 00:43 +1100
csiph-web