[Tutor] Finding items in a list
Hugo González Monteverde
hugonz-lists at h-lab.net
Mon Feb 27 16:24:38 CET 2006
As others have said, a concrete example would be great. For the time
being, sounds like maybe regular expressions could do it. We don't know
if your data is already in a list of small strings, or if it is just a
huge string.
Take a look here for an intro to RE, though:
http://www.amk.ca/python/howto/regex/
Try to send a bit more specifics, we'll be here...
Hugo
Emily Patek wrote:
> Hi -
> I am trying to break apart a list into several smaller lists based on repeating nearly identical entries. For example, every so often there is the word CLUSTER with a number after it, like CLUSTER 1. I can find them one by one, but would like to
> do a while loop for while item in list = CLUSTER X. Is there a key that I can put in that means "any text that comes after" that would go from cluster to cluster without my typing in each cluster and number? I am a very beginner programmer and am
> trying to parse a file of gene-related information that is in a not-so-easy format. I put it into a list based on lines through the splitlines() method. I also thought about splitting the text by CLUSTER and then making each item of the list into
> a string that I could then split, but couldn't get that to work either...
>
> Thanks!
> Emily
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list