title: dynamically Accessing of particular label in text file and get elements under it and again start with next word and get elements under it using python
body: <p>I have text file using it i have to access particular labels and elements under it and i have do it for other labels also similarly.</p>
  
  <pre><code>Test[v]:
  A:
  work:35,40
  test:89,87
  
  B:
  test:89,20
  
  c:
  work:56,98
  
  Wor[K]
  H:
  test:32,34
  work:43,46
  
  J:
  test:65,98
  work:56,90
  
  
  Apple[u]
  M:
  test:12,14
  work:13,18
  
  q:
  test:1,24
  work:10,68
  </code></pre>
  
  <p>This text file format i have access the particular heading and subheading and also access the elements one by one.</p>
  
  <p>mylist = ['Test[v]:','Wor[K]','Apple[u]']</p>
  
  <pre><code>test= []
      for sub_lst in myList:
          results=[]
          for i in sub_lst:
              if i.__contains__(','):
                  results.append(int(i.replace(",","")))
          test.append(results)
      print(test)
  </code></pre>
  
  <p>I have tried to access the first and print the elements under it and start to next heading.but here i do  not how end till next heading and start accessing from it.</p>
  
  <p>This is expected output below mentioned</p>
  
  <pre><code>[[Test[v]:[A:[3540,8987],B:[8920],c:[5698]],
   [Wor[K]:[H:[3234,4346],J:[6598,5690]],
   [Apple[u]:[M:[1214,1318],q:[124,1068]]]
  </code></pre>