title: Selecting random elements in a list conditional on attribute
body: <pre><code>class Agent:
      def __init__(self, state):
          self.state = state
  #initialize values
  state_0_agents = 10
  state_1_agents = 10
  numberofselections = 2 #number of agents who can choose to transition to the higher plane
  
  #list of agents
  agents = [Agent(0) for i in range(state_0_agents)]
  agents.extend(Agent(1) for i in range(state_1_agents))
  
  random.choice(agents) 
  </code></pre>
  <p>Hey there!
  So I want to randomly select a couple of agents from this Agents list whose state I will end up changing to 1. Unfortunately the random choice function selects among all the elements. However I want to randomly select only AMONG those whose state is 0.</p>
  <p>I would prefer if this could occur without creating a new list.</p>