List search

Robert Kern robert.kern at gmail.com
Fri Sep 28 17:03:21 EDT 2007


Kevin Walzer wrote:
> 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?

line == 'x11'

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list