I’m trying to learn the python scripting . Being some body who started coding in c/c++ or java i’m finding it extremely hard to find ways to write loops in python , especially for loops with conditions
I’ve a list A of string,
i need to do a specific op on these strings a pair at a time ,say xor of the strings
Also xor(a,b)=xor(b,a), hence i need to remove the redundant pair while looping
In traditional lang i would do something like
for(i=0;i<len;i++){
for(j=i+1;j<len;j++){
res[count]=xor(a[i],a[j])
count++;
}
}
So how do I implement the same with Python, I could think of iterators but is there a more efficient way , something very obvious eluding my eyes???
Python comes with batteries included, that is, most of the stuff like this is already written for you. If you want combinations of strings, there is a dedicated function for that:
or simply: