title: python double iterator in list comprehension
body: <p>so if I have 1's in all the indexes position of S and rest would be 0's. Length of the new string will be N. How do I do that in Python list comprehension</p>
  <pre><code>S= [2,5,8]
  N= 10
  Desired output: [0,1,0,0,1,0,0,1,0,0]
  </code></pre>
  <p>My Code:</p>
  <pre><code>newlist = [1 if x.__index__() == S[i]  else 0 for i in range(len(S)) for x in range(N)]
  
  My Output: [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
  </code></pre>