Re: List search

2007-09-29 Thread Bjoern Schliessmann
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

Re: List search

2007-09-28 Thread Kevin Walzer
Robert Kern wrote: > line == 'x11' > D'oh! That was simple, wasn't it? *smacks head* That did the trick. Thanks! -- Kevin Walzer Code by Kevin http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list

Re: List search

2007-09-28 Thread Tim Williams
On 28/09/2007, Kevin Walzer <[EMAIL PROTECTED]> 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

Re: List search

2007-09-28 Thread Robert Kern
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

Re: List search

2007-09-28 Thread Stefan Bellon
On Fri, 28 Sep, 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 Just compare for equality: if line == 'x11': or print "\n".join(x

List search

2007-09-28 Thread Kevin Walzer
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'. Ho