On Nov 09, Dennis Benzinger wrote: > Use the re module: > > import re > your_data = """person number 1 > > Name: bob > Age: 50 > > > person number 2 > > Name: jim > Age: 39""" > > names = [] > for match in re.finditer("Name:(.*)", your_data): > names.append(match.group(1)) > print names
Dennis' solution is correct. If you want to avoid REs, and concision and speed are premiums, then you might refine it to: names = [line[5:].strip() for line in your_data.split('\n') if line.startswith('Name:')] -- _ _ ___ |V|icah |- lliott http://micah.elliott.name [EMAIL PROTECTED] " " """ -- http://mail.python.org/mailman/listinfo/python-list