Hi,
I´m new to Python and right now I´m trying to learn to parse a text.
Here is my code (that doesn´t work the way I want)
text = ['Mary', 'went', 'out', 'at', '7pm', 'to','buy','some','candy']
keyPerson = ['Mary', 'Clark', 'Steven']
keyTime = ['7pm', '6am', '2pm']
keyThing =['candy','eggs','fruit']
list = []
for current in text:
for e in keyPerson:
if e in current:
print '--------->''%s'%e
for f in keyTime:
if f in current:
print '--------->''%s'%f
for g in keyThing:
if g in current:
print '--------->''%s'%g
else:
list.append(current)
print list
The way I want it separated is:
#'Mary'
#'7pm'
#'candy'
#'went out at to buy some'
How can I do this?