how to convert data into list in python
<p>I have sample dataset A. It looks like:</p>

<pre><code>1:CH,AG,ME,GS;AP,CH;HE,AC;AC,AG
2:CA;HE,AT;AT,AC;AT,OG
3:NE,AG,AC;CS,OD
</code></pre>

<p>The expected result should be:</p>

<pre><code>['CH','AG','ME','GS','AP','CH','HE','AC','AC','AG','CA','HE','AT','AT','AC','AT','OG','NE','AG','AC','CS','OD']
</code></pre>

<p>I am not sure how to write the code in Python to a list.</p>

<p>One option would be to locate all 2 consecutive upper-case letter cases with a regular expression:</p>

<pre><code>In [1]: import re

In [2]: data = """
   ...: 1:CH,AG,ME,GS;AP,CH;HE,AC;AC,AG
   ...: 2:CA;HE,AT;AT,AC;AT,OG
   ...: 3:NE,AG,AC;CS,OD"""

In [3]: re.findall(r"[A-Z]{2}", data, re.MULTILINE)
Out[3]: 
['CH',
 'AG',
 'ME',
 'GS',
 'AP',
 'CH',
 'HE',
 'AC',
 'AC',
 'AG',
 'CA',
 'HE',
 'AT',
 'AT',
 'AC',
 'AT',
 'OG',
 'NE',
 'AG',
 'AC',
 'CS',
 'OD']
</code></pre>

python list