I have a really really simple question that I struggle with :)
I need to iterate over list of truples in means of lower triangle matrix in python
python code
dataset = #list of truples
for i, left in enumerate(dataset):
for j, right in enumerate(dataset):
if j <= i : continue #fixme there should be a better way
foo(left,right)
target pseudo code
for( i=0; i<size; i++ )
for( j=i; j<size; j++ )
foo(data[i],data[j])
Thank you very very much :)
Based on the pseudo code this should be something like this:
for i in range(0, len(data)):
for j in range(i, len(data)):
foo(data[i],data[j])
also u can do it with one liner:
[foo(data[i],data[j]) for i in range(0, len(data)) for j in range(i, len(data)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With