I have a list of elements [1, 2, 3, 4, 5], I want to generate combinations one by one, like [1, 2, 3], [2, 4, 5], etc.
I tried using itertools.combinations but that makes a list of all possible combinations, which takes up too much memory space.
How do I access each new combination right when it is generated?
list(itertools.combinations(a,3))
wherea = [1,2,3,4,5]
- Sruthi Vgenerator
? - Zhiya