how to stop a for loop <p>I am writing a code to determine if every element in my nxn list is the same. i.e. [[0,0],[0,0]] returns true but [[0,1],[0,0]] will return false. I was thinking of writing a code that stops immediately when it finds an element that is not the same as the first element. i.e:</p> <pre><code>n=L[0][0] m=len(A) for i in range(m): for j in range(m): if L[i][j]==n: -continue the loop- else: -stop the loop- </code></pre> <p>I would like to stop this loop if <code>L[i][j]!==n</code> and return false. otherwise return true. How would I go about implementing this?</p>