HELP Newbie solve this Problem

Dennis Lee Bieber wlfraed at ix.netcom.com
Sat Mar 25 00:00:06 EST 2000


On Fri, 24 Mar 2000 19:06:25 -0500, Mark Hathaway
<hathawa2 at marshall.edu> declaimed the following in comp.lang.python:

> I can't really believe the Fartran code takes that much space.
> I suspect it's given as a set-up, so the Python code to follow
> will be all the more impressive. Well, here's a Python version.
> 
> import string
> lines = open('file.txt').readlines()
> for each in lines:
>     eachlist = string.split(each)
>     str = eachlist[1] + " " + eachlist[0]
>     print str
> 
> If you'd wanted the output printed back to a file then you could
> add something other than the final 'print str' statement.
> 
> Amazing isn't it? When a language doesn't get in your way the code
> is brief and more readable. It's all the niggling little details
> that a language like Fortran or C require that makes them very ugly.
>
	I think either you missed a requirement, or I went too far...
>From the original poster:

history> The “data?” file is the preamble to the constitution.
history> The objective is to write a command that will give a list of
how many
history> times the letters appear in the preamble. Try not to use awk.

 The original program input is not that list of numbers and letters, but
plain text to be counted (ignoring case and punctuation/numerics). I was
just surprised the example output implied that the <character><count>
format was more difficult to produce than the <count><character>
ordering...

--
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list