Calculate all unique permutations using nested loops in Python -


what python equivalent implementation c++ code:

char x[10]; (int i=0; < 10; i++) {     (int j=i; j < 10; j++) {         calc_something(x[i], x[j])     } } 

thank you

here solutions don't use imports, , assuming x declared list containing 10 elements:

for in range(10):  # xrange in python 2     j in range(i, 10):         calc_something(x[i], x[j]) 

or using enumerate function:

for i, el in enumerate(x):     j in x[i:]:         calc_something(el, j) 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -