On Mon, Jan 13, 2014 at 1:36 AM, Rotwang <sg...@hotmail.co.uk> wrote: > On 12/01/2014 05:58, Chris Angelico wrote: >> >> (BTW, is there no better notation than six nested for/range for doing >> 6d6? I couldn't think of one off-hand, but it didn't really much >> matter anyway.) > > > If you're willing to do an import, then how about this: > >>>> from itertools import product >>>> len([x for x in product(range(1, 7), repeat = 6) if sum(x) < 14])/6**6 > 0.03587962962962963
Should have known itertools would have something. That's a little more complicated to try to explain, but it's a lot shorter. ChrisA -- https://mail.python.org/mailman/listinfo/python-list