On Sun, Dec 29, 2013 at 4:02 PM, Jing Ai <jai...@g.rwu.edu> wrote:

> Hello,
>
> I am trying to rewrite some contents on a long list that contains words
> within brackets and outside brackets and I'm having trouble extracting the
> words within brackets, especially since I have to add the append function
> for list as well.  Does anyone have any suggestions? Thank you!
>
> *An example of list*:
>
> ['hypothetical protein BRAFLDRAFT_208408 [Branchiostoma floridae]\n',
> 'hypoxia-inducible factor 1-alpha [Mus musculus]\n', 'hypoxia-inducible
> factor 1-alpha [Gallus gallus]\n' ]
>

Is the above line a python  list, or is it what you get when you read a
line of a data file.  The reason I ask, is if it is a list you can split
the list by looping of each list item.  Then just maybe try some of these
ideas:

http://stackoverflow.com/questions/10017147/python-replace-characters-in-string

> *What I'm trying to extract out of this*:
>
> ['Branchiostoma floridae', 'Mus musculus', 'Gallus gallus']
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Joel Goldstick
http://joelgoldstick.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to