My string contains large paragraph like this:
Line= \"
Name = AB | 1-2 | Name
ID = CD | 3-4 | int
Stu
EDIT: Used your string.
Note: There's probably a cleaner way to do this.
You can use regex:
>>> import re
>>> Line = """
Name = AB | 1-2 | Name
ID = CD | 3-4 | int
Stu = EF | 5-6 | Name
Email = GH | 7-8 | string
ID = IJ | 9-10 | int
Tea = KL | 1--12 | Name
Email = MN | 13-14 | Name
ID = OP | 1-2 | int """
>>> Line = '\n'.join(i.lstrip() for i in Line.strip().splitlines())
>>> newlist = [i.strip('\n') for i in re.split(r'ID.*',Line)]
>>> print newlist[0]
Name = AB | 1-2 | Name
>>> print newlist[1]
Stu = EF | 5-6 | Name
Email = GH | 7-8 | string
>>> print newlist[2]
Tea = KL | 1--12 | Name
Email = MN | 13-14 | Name