In Python, is there a good way to end a while loop when a list does not change?
I am trying to implement the k means algorithm, which involves finding the centroids of groups of data points. Once the centroid positions no longer change, the loop is terminated.
I know that I could save the list of centroids at the beginning of the loop, and then make the while loop continue until the previous centroids match the current. But is there a more pythonic way of doing this?