<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">You can break the loop when you get a
      positive matches, and add a variable where you can count the
      number of positive matches, if it's equal to zero print 'not
      found'<br>
      <br>
      On 24/10/2012 17:43, Saad Javed wrote:<br>
    </div>
    <blockquote
cite="mid:CAJ5mJ2u1QJW9ATf=_VmXnchKthKHiwhuKLMu24RfVS4AtELKuA@mail.gmail.com"
      type="cite">Let me modify this example:
      <div><br>
      </div>
      <div>
        <div>a = [['jimmy', '25', 'pancakes'], ['tom', '23',
          'brownies'], ['harry', '21', 'cookies']]</div>
        <div>
          for i in a:</div>
        <div>    <b>b = i[0]</b></div>
        <div>    if (i[1] == '25' or i[1] == '26'):</div>
        <div>        print <b>b</b></div>
        <div>    else:</div>
        <div>        print 'Not found'</div>
        <div><br>
        </div>
        <div>This will output:</div>
        <div><b>jimmy</b></div>
        <div><b>Not found</b></div>
        <div><b>Not found</b></div>
        <div><b><br>
          </b></div>
        <div>How do I print positive matches (<b>jimmy</b>) only and not
          (<b>Not found</b>). I also want <b>Not found </b>to print
          only <i>once </i>if there are no positive matches.</div>
        <div><br>
          On Wednesday, October 24, 2012, Saad Javed wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,
            <div><br>
            </div>
            <div>
              <div>a = [['jimmy', '25', 'pancakes'], ['tom', '23',
                'brownies'], ['harry', '21', 'cookies']]</div>
              <div>for i in a:</div>
              <div>    if (i[1] == '25' or i[1] == '26'):</div>
              <div>        print 'yes'</div>
              <div>else:</div>
              <div>    print 'Not found'</div>
            </div>
            <div><br>
            </div>
            <div>This prints:</div>
            <div>yes</div>
            <div>not found</div>
            <div><br>
            </div>
            <div>I want it to print "yes" for each positive match but
              nothing for a negative match. However if all matches are
              negative, I want it to print "Not found" once (That bit
              the code already does). I do I get it to print "yes" only
              in a mix result situation?</div>
            <div><br>
            </div>
            <div>Saad</div>
          </blockquote>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Tutor maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:Tutor@python.org">Tutor@python.org</a>
To unsubscribe or change subscription options:
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>