sorting

Emile van Sebille emile at fenx.com
Thu Feb 28 10:35:56 EST 2002


"Jeff McComas" <jmackd1 at yahoo.com> wrote in message
news:3c7e3d12_7 at news.teranews.com...
> As a newbie i find the python scripting language very interesting and
useful.
> I am trying to write a script that will search a .txt file and have
the script
> tell me how many of the same numbers are in the .txt file. I know you
can do
> it with the f.count command but my problem is how can you do an input
that
> makes the numbers strings? Or puts double quotes and a comma around a
number?


When you read the .txt file you get strings.  Use split to make a list,
use the list elements as keys in a dict where the accumulated count is
the value.  You may want to start with:

vals = """ 34.6        25        78        89.2       45.7
 23          92        47        20         85
 56          78        23        49         92 """

and add the file reading part later.


Post your efforts next time so we can point out specific problems and
answers.

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list