1

I have an array of values like this:

0129 4589 4878 7895

I would like to iterate through the entire array and leave one row out in each turn to have this:

0129 4589 4878

0129 4589 7895

0129 4878 7895

4589 4878 7895

.... and so forth

I am aware of the itertools 'combinations' in python. Is there away I can apply the funciton to a whole row of the array rather than indivdual values of a row?

1
  • 3
    What is a "row"? What is an "array"? Can you be more specific? Post some code. Commented Apr 25, 2012 at 19:14

1 Answer 1

2

You have the answer I think

itertools.combinations(array, 3)

would produce this output

i.e.,

>>> [x for x in itertools.combinations([123,345,543,234],3)]
[(123, 345, 543), (123, 345, 234), (123, 543, 234), (345, 543, 234)]
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much! That was very helpful, I just had restructure my thinking about a function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.