def find(chambre, etiquette): """Find all occurence of etiquette in chambre and return a list of all his position :chambre: matrice of item in chambre :etiquette: Element to find in chambre as string :returns: list of positions """ ret = list() for x in range(len(chambre)): for y in range(len(chambre[x])): if etiquette == chambre[x][y]: ret.append((x,y)) return ret # Tests if __name__ == "__main__": chambre = [ [ "A" , "A" , "B" , "D" ], [ "C" , "P" , "U" , "A" ], [ "M" , "O" , "N" , "S " ], [ "A" , "B" , "D" , "A" ] ] print(find(chambre, 'A'), "should print 5 elemets") print(find(chambre, 'C'), "Should print 1 element") print(find(chambre, 'Elephant'), "Should print nothing")