Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のリストがあります
Values=[ 0 , 1 , 2 ]
私の目的は、以下を生成することです
MySums=[1+2,0+2,0+1]
組み合わせのための組み込み関数はありますか?
import itertools >>> values=[ 0 , 1 , 2 ] >>> [ sum(list(i)) for i in itertools.combinations(values,2)] [1, 2, 3] >>>