Python creating a list with itertools.product?

前端 未结 3 1449
野的像风
野的像风 2021-02-20 04:48

I\'m creating a list with itertools from a list of ranges, so far I have this:

start_list = [xrange(0,201,1),xrange(0,201,2),xrange(0,201,5),xrange(0,201,10),xra         


        
3条回答
  •  醉酒成梦
    2021-02-20 05:27

    Better to just use a list comprehension

    new_list = [item for item in itertools.product(*start_list) if sum(item) == 200]
    

提交回复
热议问题