title: How to slice a list of strings till index of matched string depending on if-else condition
body: <p>I have a list of strings = </p>
  
  <pre><code>['after','second','shot','take','note','of','the','temp']
  </code></pre>
  
  <p>I want to strip all strings after the appearance of 'note'.
  It should return </p>
  
  <pre><code>['after','second','shot','take']
  </code></pre>
  
  <p>There are also lists which does not have the flag word 'note'.</p>
  
  <p>So in case of a list of strings = </p>
  
  <pre><code>['after','second','shot','take','of','the','temp']
  </code></pre>
  
  <p>it should return the list as it is.
  How to do that in a fast way? I have to repeat the same thing with many lists with unequal length. </p>
  
  <pre><code> tokens = [tokens[:tokens.index(v)] if v == 'note' else v for v in tokens]
  </code></pre>