[Tutor] second if

Alan Gauld alan.gauld at btinternet.com
Mon Feb 10 12:24:39 CET 2014


On 07/02/14 16:14, rahmad akbar wrote:
> he guys, i am trying to understand this code: i understand the first if
> statement (if line.startswith..) in read_fasta function but couldnt
> understand the next one(if index >=...). thanks in advance!!

I'm not sure what you don't understand about it.
But so far as I can see its effect is to miss out
the first line in the file that starts with '>'

The logic appears to be, in pseudo code:

read the file line buy line
      if line starts with >
          if not the first time add instance to the collection
      add one to index
      create an instance.

It has to miss the first one because an instance doesn't
exist yet. It seems odd and I'd probably have done it this
way:

read the file line buy line
      if line starts with >
         create an instance.
         add instance to the collection

But there may be reasons why the author didn't do that.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list