Given a list like alist = [1, 3, 2, 20, 10, 13], I wanna write a function find_group_f, which can generate all possible combination of elements in alist and meanwhile I can dynamically control the number k of element in each group. For instance, if the number k is 2, the function is equal to:
for e1 in alist:
for e2 in alist[alist.index(e1)+1:]:
print (e1, e2)
While the number k is 3, it would be like:
for e1 in alist:
for e2 in alist[alist.index(e1)+1:]:
for e3 in alist[alist.index(e2)+1:]:
print (e1, e2, e3)
I wonder how can I implement like this? Thanks in advance!