[Tutor] if >= 0

rahmad akbar matbioinfo at gmail.com
Mon Feb 10 16:32:19 CET 2014


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:
  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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140210/a6a55d2a/attachment.html>


More information about the Tutor mailing list