on writing a while loop for rolling two dice
Chris Angelico
rosuav at gmail.com
Mon Aug 30 10:31:45 EDT 2021
On Tue, Aug 31, 2021 at 12:28 AM Peter Otten <__peter__ at web.de> wrote:
>
> 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;)
Thank you, I appreciate that :)
> > 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...
>
Are there any linters that warn against "unintuitive use of
two-argument iter()"?
ChrisA
More information about the Python-list
mailing list