title: Python combined condition operators: if AA in Y or BB in Y and not B in Y
body: <p>I want to run this code as "if <code>'Britain'</code> or <code>'UK'</code> in string do stuff, but don't do stuff if <code>"Ex UK"</code> is in string":</p>
  
  <pre><code>#Case insensitive wrapper - equivalent to if X in Y
  def case_in(phrase, string):
      return phrase.lower() in string.lower()
  
  name = "Developed Europe Ex UK Property"
  
  #This is the relevant part
  if case_in("Britain", name) or case_in(" UK ", name) and not case_in("Ex UK", name):
      geofocusregion = "Europe"
      geofocuscountry = "GB"
      fundcurrency = "GBP"
  </code></pre>
  
  <p>However, for a string where <code>"Ex UK"</code> is included, it still sets the variables, e.g. <code>geofocuscountry = GB</code>.</p>