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=')):

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to