A Program that prints the numbers from 1 to 100
Chris Angelico
rosuav at gmail.com
Mon Nov 16 07:35:37 EST 2015
On Mon, Nov 16, 2015 at 10:57 PM, <harirammanohar159 at 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
More information about the Python-list
mailing list