[Tutor] if >= 0
Joel Goldstick
joel.goldstick at gmail.com
Mon Feb 10 17:00:15 CET 2014
On Feb 10, 2014 10:33 AM, "rahmad akbar" <matbioinfo at gmail.com> wrote:
>
> hey again guys, i am trying to understand these statements,
>
> if i do it like this, it will only print the 'print locus' part
>
> for element in in_file:
# do this
print element
> if element.find('LOCUS'):
> locus += element
> elif element.find('ACCESSION'):
> accession += element
> elif element.find('ORGANISM'):
> organism += element
>
> print locus
> print accession
> print organism
>
>
> once i add >= 0 to each if conditions like so, the entire loop works and
prints the 3 items
>
> for element in in_file:
> if element.find('LOCUS') >= 0:
> locus += element
> elif element.find('ACCESSION') >= 0:
> accession += element
> elif element.find('ORGANISM') >= 0:
> organism += element
>
> print locus
> print accession
> print organism
>
> why without '>= 0' the loop doesnt works?
> --
> many thanks
> mat
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140210/2e7d520c/attachment.html>
More information about the Tutor
mailing list