vendredi 6 avril 2018

How to get a pair of element from a list with certain condition?

Let us consider the following example :

n=int(raw_input('Enter an integer n= '))
L=range(n)
V=[]

for i in L:
    print i
    for j in L:
    if (j!=i) and (i==(n*j)%n or j==(n*i)%n)
            V.append((i,j))

The elements of M should like the form M=[(i,j),...]

The above code gave me errors. How can I fix this.

Aucun commentaire:

Enregistrer un commentaire