Scott Miller 🇺🇦 🇺🇸<p>Python Question: Is there an efficient way to see if every element in an iterable is equal to a user-specified value?</p><p>The best idea I've seen so far is to use a list comprehension to check for equality, and then use the all function, like this:<br> MyList = [1,1,1,1,1,1,1]<br> all((x==1 for x in MyList))</p><p>That's readable and probably not bad performance. Is there something better?</p><p><a href="https://mstdn.social/tags/Python" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Python</span></a> <a href="https://mstdn.social/tags/PythonQuestion" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>PythonQuestion</span></a></p>