title: Python3: TypeError: list indices must be integers or slices, not str
body: <p>I have my data stored in json format. And by using json:load() I am reading the data.</p>
  <p>What I am trying to do is based on argument passed , I am trying to extract specific part of Key:Value from the list and storing them into a new list for later processing.</p>
  <h1>Code</h1>
  <pre><code>selected_env='mydev2'
  server_list=[{'mydev': ['192.168.56.102', '192.168.56.102', '192.168.56.102']}, {'mydev2': ['192.168.56.102', '192.168.56.102', '192.168.56.102']}]         
  for item in server_list :
      host_list=[item for item in server_list[selected_env] if selected_env in server_list]
  
  print(host_list)
  </code></pre>
  <p>And I am getting error as</p>
  <p><code>TypeError: list indices must be integers or slices, not str</code></p>
  <p><strong>Note</strong>: I have achieved already one way of extraction as below</p>
  <pre><code>for item in server_list:
    for element in item :
      if element == selected_env :
         host_list=item[selected_env]  
  </code></pre>
  <p>even though its working, I thought of optimizing it and went to read some articles on list extraction and kind of stuck with above error.</p>
  <p>Any help, greatly appreciated.</p>