Python creating a list with itertools.product?

前端 未结 3 1234
有刺的猬
有刺的猬 2021-02-20 04:40

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:29

    Better to just use a list comprehension

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

提交回复
热议问题