on writing a while loop for rolling two dice

Peter Otten __peter__ at web.de
Mon Aug 30 10:20:16 EDT 2021


On 30/08/2021 15:50, Chris Angelico wrote:

> def how_many_times():
>      return next((count, rolls) for count, rolls in
> enumerate(iter(roll, None)) if len(Counter(rolls)) == 1)


That's certainly the most Counter-intuitive version so far;)


> Do I get bonus points for it being a one-liner that doesn't fit in
> eighty characters?

Nah, but you'll get an honorable mention when you run it through 
pycodestyle without line break...



More information about the Python-list mailing list