On 17/10/12 12:10:56, Anatoli Hristov wrote: > I'm trying to index a text in a list as I'm importing a log file and > each line is a list. > > What I'm trying to do is find the right line which contains the text > User : and take the username right after the text "User :", but the > list.index("(User :") is indexing only if all the text matching. How > can I have the right position of the line which contains the word > ("(User :")
Perhaps something like: target = "(User :" for line in your_list: position = line.find(target) if position >= 0: print line[position+len(target):] Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list