Exploring Bioinformatics with Python

Converting strings to lists

We often want to convert strings to lists of their component characters. The instructions for doing so are simple and concise. We just apply the list function to the string. For example,

>>> list('ACACCTA')
['A', 'C', 'A', 'C', 'C', 'T', 'A']
>>> list('')
[]
>>> list('ACTacgGCA')
['A', 'C', 'T', 'a', 'c', 'g', 'G', 'C', 'A']

See also:


This page was generated by Siteweaver on Thu Sep 10 09:37:01 2009.
The source to the page was last modified on Thu Sep 10 09:20:24 2009.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/ExBioPy/string-to-list.html.

You may wish to validate this page's HTML

Samuel A. Rebelsky
rebelsky@grinnell.edu