k-combinations in Python 3.x -
what efficient way generate k-tuples k-combinations given python set? there appropriate built-in function? tells me should possible two-line loop.
p.s. did conduct search , found various entries topic "combinations lists, etc in python", proposed solutions seem rather 'un-python'. hoping mind-blowing, idiomatic python expression.
itertools
has of types of functions:
import itertools combination in itertools.combinations(iterable, k): print(combination)
Comments
Post a Comment