[Tutor] character counting

Alan Gauld alan.gauld at btinternet.com
Sun Mar 23 17:23:19 CET 2014


On 23/03/14 06:28, Mustafa Musameh wrote:
> Hi;
> I have a file that looks like this:
>  >title 1
> AAATTTGGGCCCATA...
> TTAACAAGTTAAAT…
>  >title 2
> AAATTTAAACCCGGGG…
> ATATATATA…
>>


> I want to get the following out put:
>
>  >title
> 234
>  >title 1
> 3453
> ….

Your example data and example output don't match - at least
not in any way I can see.

Can you provide sample input and output from that sample?
That will help us understand exactly what you want.

It might be useful to break the code into functions so that
you have one to read the lines and if appropriate call a
second that analyzes a line returning the counts. Then
a third function can print the results in the format
you want. An optional fourth function could assign the
analysis results to the dictionary but that's probably
overkill.

You could even ignore the first one and just make
it your main driver code, but the second and third would
be helpful in testing and make the main code easier
to read.


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