title: how to use Assignment Expressions to check what was matched by any()
body: <p>I am confused with Assignment Expressions (<a href="https://peps.python.org/pep-0572/" rel="nofollow noreferrer">https://peps.python.org/pep-0572/</a>). According to this question (<a href="https://stackoverflow.com/questions/41728329/how-to-find-what-matched-in-any-with-python">How to find what matched in any() with Python?</a>) I can use Assignment Expressions to find what was matched by any().</p>
  <p>Simple example:</p>
  <pre class="lang-py prettyprint-override"><code>
  look = &quot;abc&quot;
  
  mylist = [&quot;abcde15&quot;, &quot;nonono&quot;]
  
  if any((match := look) in s for s in mylist):
      print(f&quot;I found {look} v {mylist}&quot;)
  
  # I found abc v ['abcde15', 'nonono']
  </code></pre>
  <p>But how can I get <code>abcde15</code> which is what I found in mylist? Thanks</p>