title: how to create dictionary or json from list of strings in python?
body: <p>I am trying to create dictionary or json from list of strings which is going to be value for dictionary and I have dictionary key that going to be match value. I think it is intuitive for me to get this done, but I have following error:</p>
  
  <pre><code>&gt; Traceback (most recent call last):
  &gt;     output[elm].append(k) TypeError: list indices must be integers or slices, not str
  </code></pre>
  
  <p>I am curious what cause this problem. can anyone point me out what is wrong with me code?</p>
  
  <p><strong>my attempt</strong></p>
  
  <p>here is my code:</p>
  
  <p><strong>update</strong></p>
  
  <pre><code>lst = {api, 1,0,0}
  mystring = lst.split(",")
  
  mystring = ['api', '1', '0', '0']
  names = {'name', 'mayor', 'minor', 'patch'}
  
  output =[]
  for elm in range(len(names)):
      for k in range(len(mystring)):
          output[elm].append(k)
  
  print(output)
  </code></pre>
  
  <p>how can I fix the error? Is there efficient way to make dictionary or json from list of strings without using nested for loop? any better idea?</p>
  
  <p><strong>desired output</strong>:</p>
  
  <p>I want to get dictionary or json something like this:</p>
  
  <pre><code>{
    "mayor": 1,
    "minor": 0,
    "name": "api",
    "patch": 0
  }
  </code></pre>
  
  <p>I am sorry if my coding defect is minor, I couldn't locate source of the problem. thanks</p>