title: How can I modify a variable in a list comprehension?
body: <p>Is there any way to reassign <code>alt_index</code> once per loop run in the following code?</p>
  <pre><code>alt_index = random.randint(0, len(validinfo) - 1)
  </code></pre>
  <p>To that list:</p>
  <pre><code>futures = [
      session.post(f&quot;https://api.mojang.com/user/profile/{validinfo[alt_index].rpartition(':')[-1].rpartition(':')[-1]}/name&quot;, headers={'Authorization': &quot;Bearer &quot;+validinfo[alt_index].rpartition(':')[0].rpartition(':')[-1]}, json={&quot;name&quot;: TARGET,&quot;password&quot;: validinfo[alt_index].rpartition(':')[0].rpartition(':')[0].rpartition(':')[-1]})
      for i in range(TRIES)
  ]
  </code></pre>
  <p>Every request should use a different <code>alt_index</code> but in the same expression it must be the same.
  I use this to make every request use different data from a txt file.
  When I add <code>alt_index = random.randint(0, len(validinfo) - 1)</code> to list it throws an error, I don't know how can I fix this.</p>