jeudi 23 avril 2020

Pair of coordinate from list whose y axis is equal and x axis is bigger or smaller by 1 with one another

So from the coordinates list, the found will be [(6,3),(5,3)]. I dont know how to fix my code.

Coordinates=[(6, 3),(4, 2),(5,3),(2,4)]
ix=0
Found =[]
    for c in coordinates:
        if ((c[0]+1,c[1]) in coordinates) and ((c[0]-1,c[1]) in coordinates):
            ix+=1
            Found.append(c)
            Found.append(c[ix+1])
            break

Aucun commentaire:

Enregistrer un commentaire