List search

Kevin Walzer kw at codebykevin.com
Fri Sep 28 16:48:27 EDT 2007


I'm having a problem with searching a list. Here's my code:

mylist = ['x11', 'x11-wm', 'x11-system']

for line in mylist:
	if 'x11' in line:
		print line

This results in the following output:

x11
x11-wm
x11-system

I'm looking to return the list item that just has 'x11'.  How can I 
structure my search term so that this output is returned?



More information about the Python-list mailing list