リスト S から 2 つの整数のサブセットを見つけるために、以下のコードを書きました。
import itertools
S = [1, 2, 3, 4, 6]
subsets = itertools.combinations(S, 2)
print subsets
私は以下の結果を期待しています:
[[1, 2], [1, 3], ... [4, 6]]
上記のコードから次のようなエラーが発生しました。
Traceback (most recent call last):
Line 5, in <module>
subsets = itertools.combinations(S, 2)
AttributeError: 'module' object has no attribute 'combinations'
組み合わせ () をインポートできないのはなぜですか?