title: Create boolean list based on index ranges in python
body: <p>For some reason I am trying to create a boolean list of given length with the default <code>False</code>. Furthermore I know the index range(s) to be set to <code>True</code>.
  I have to do that several times and for readability dont want to write out every list manually (neither with <code>0</code> and <code>1</code> and convert it), but write the actual index ranges, e.g. <code>range(2, 5)</code>.</p>
  
  <p>I would like to have one-liner for every variable, but I simply do not seem to be able to get this done. </p>
  
  <pre class="lang-py prettyprint-override"><code>index_length = 10
  raw = [False] * index_length
  # raw = np.array(raw)
  var1 = [
    list(range(2,5)) + list(range(6,9)),
    list(range(0, 9),
    [],
  ]
  </code></pre>
  
  <p>Iterating through <code>var1</code> should result in a new variable <code>var2</code> as stated below, whereas the elements can either be binary integer or boolean values.</p>
  
  <pre class="lang-py prettyprint-override"><code>var2 = [
    [0, 0, 1, 1, 1, 0, 1, 1, 1, 0],
    [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  </code></pre>
  
  <p>I dont need a function which iterates through every element of the sublists of <code>var1</code>, but something like this.</p>
  
  <pre class="lang-py prettyprint-override"><code>var2 = [None] * len(var1)
  for idx  in var1:
    var2[idx] = ...
  </code></pre>
  
  <p>I thought there must be some list comprehension or something, but I failed for quite some time now. I tried using the raw list/numpy array but couldnt assign it to <code>var2</code> and edit the boolean values in one line
  Maybe it is so easy I dont see it, maybe it is not possible at all, maybe python is not designed to do that but Id like to try anyways.</p>
  
  <p>PS: I have spent that much time on it now, that I cant tell if my question explains my problem well, if not I am sorry in advance.</p>