title: Python Dict: TypeError: list indices must be integers, not str
body: <p>This piece of code is from a script that obtains the PDB (Protein Data Bank) code which contain the UniProt code store in a dictionary: DDomainSeq. </p>
  
  <p>This is a sample of DDomainSeq Dic:</p>
  
  <pre><code>{'3.30.67.10': ['G3GAK5', 'I3QCE1', 'G3EN69', 'K4LBV0', 'Q2XWS4', 'D6MQ73', 'F1D844', 'Q8JTJ9', 'H9U1G9', 'B1PNF1', 'B3F7E1', 'Q9J0E6', 'K4LBK6', 'Q2XRW4', 'D0EPQ6', 'D3U0G6', 'Q8QMF3', 'J9PQ44', 'B9W116', 'Q2XRW9', 'I3QCH7', 'K7R4A7', 'I7B1H2', 'B1PNH0', 'I3QCD9', 'Q82861', 'I3QC33', 'Q2XRJ4', 'E3UMQ4', 'B9V561', 'Q8BE43', 'Q80QJ9', 'E0YAP9'], '2.60.98.10': ['C9WJC0', 'B3TN06', 'Q9IZI7', 'Q9WDA0', 'A9LIM6', 'C5MSX3', 'Q6Q6Q1', 'Q3LFV0', 'E5RCU8', 'I6XG39', 'G5EJD7', 'D3X8F0', 'Q2XRV6', 'D0QXC4', 'I7EMG2', 'A4UIW9', 'Q89283', 'H9M657', 'F2YLD8', 'Q2YGV6', 'D6MQ23', 'G9F8Y6', 'G8G189', 'H8Y6K8', 'E3UMP9', 'Q91AG4', 'I3QCA4', 'A4K4T3', 'H6VBW8', 'D8FSI8', 'D0TYZ3', 'I3QCM1', 'H6VBX9', 'C0JZP9', 'C6ZE88', 'A1BY35', 'I7A3V7', 'Q2XRZ1', 'A5YBK7', 'Q66463', 'C3V004', 'Q6YG48', 'Q2ESB0', 'H1ZYK5', 'Q00P61', 'E2IZW1', 'D0VF46', 'K4IYH8', 'Q9IJX6', 'Q87046', 'Q9WB77', 'C7T0M1', 'I3QC70', 'E2IGI0', 'Q32ZL8', 'C8CKT7', 'D6MM36', 'Q3LFN6', 'F5AXV2', 'I6PGU1', 'B9W157', 'K7PP62', 'Q3Y6G7', 'Q6YFX6', 'C9WPK5', 'G9IBD9', 'G9DR11', 'C1KKF7', 'I6WJM3', 'K7PPW7', 'Q3S2G1', 'Q6WP68', 'H2D5H7', 'H2D5I3', 'K7QRY5', 'Q9WLZ8', 'F5AXW1', 'Q8JTJ2', 'E3UMM2', 'B9VHE4', 'B6E979', 'Q2YH31', 'A7TUC9', 'D3X8C3', 'H2D5I2', 'B6EBW6', 'F2WS10', 'Q2YH68', 'C1KKE8', 'B0LCR1''A3GPY8']}
  </code></pre>
  
  <p>Each one of the elements within each key are use to search for a PDB file found in the PDBSum Data base.</p>
  
  <pre><code>PDBSumWWW = urllib.urlopen("https://www.ebi.ac.uk/thornton-srv/databases/pdbsum/data/seqdata.dat")
  PDBSum = PDBSumWWW.read().splitlines()
  PDBSumWWW.close()
  </code></pre>
  
  <p>This is the code I use for this:</p>
  
  <pre><code>for domain in dDomainSeq.keys():
      print domain 
      PDB = []
      for  uni in dDomainSeq[domain]:
          for i in range(len(PDBSum)):
              if "SWS_ID" in PDBSum[i]:
                  str = PDBSum[i]
                  splited = str.split()
                  if uni in splited[2]:
                      PDB.append(splited[0])
      print PDB
      print len(PDB)
      PDBSum[domain]=PDB
  </code></pre>
  
  <p>However after loading all PDB-UniProt Code matches the first key "3.30.67.10" it reveals the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/ThePoet/Dropbox/MBID/MSc Summer Project/Program/SeqPDBSum.py", line 57, in &lt;module&gt;
      main()
    File "/Users/ThePoet/Dropbox/MBID/MSc Summer Project/Program/SeqPDBSum.py", line 45, in main
      PDBSum[domain]=PDB
  TypeError: list indices must be integers, not str
  </code></pre>