On Mar 6, 1:28 am, MRAB <goo...@mrabarnett.plus.com> wrote: > Aahz wrote: > > In article <mailman.9538.1234633556.3487.python-l...@python.org>, > > Terry Reedy <tjre...@udel.edu> wrote: > >> for line in open('char.txt'): > >> if line.find('sweet') != -1 or line.find('blue') != -1: > >> print(line) > > > For any recent Python, this should be: > > > if 'sweet' in line or 'blue' in line: > > > Although I think that for the OP's use case, it ought to be: > > > if line.startswith('sweet=') or line.startswith('blue=') > > Or: > > if line.startswith(('sweet=', 'blue=')):
C'est magnifique mais ce n'est pas la guerre ... c'est "bassackwards" ** 2: (1) 'Mango' is the query, 'sweet' is the desired result (2) The line, after stripping \n, *ends* with 'sweet' And it's not robust in the face of likely whitespace either side of the '=' -- http://mail.python.org/mailman/listinfo/python-list