Re: [Tutor] Dictionary File character reader

2011-05-10 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Clara Mintz wrote: Sorry I am completely new at python and don't understand why this function is returning an empty dictionary. I want it to take a list of files open them then return the number of characters as the value and the file name as the key. def fileLengths

Re: [Tutor] Dictionary File character reader

2011-05-10 Thread Alan Gauld
"Noah Hall" wrote What you want is something that takes the length of each line, and add it to the sum. A simple way would be to do sum(len(line) for line in file) And if you just want the total count for the file an even simpler way is to use file.read() count = len(file.read()) One

Re: [Tutor] Dictionary File character reader

2011-05-09 Thread Noah Hall
On Tue, May 10, 2011 at 5:27 AM, Clara Mintz wrote: > Sorry I am completely new at python and don't understand why this function > is returning an empty dictionary. I want it to take a list of files open > them then return the number of characters as the value and the file name as > the key. > def

[Tutor] Dictionary File character reader

2011-05-09 Thread Clara Mintz
Sorry I am completely new at python and don't understand why this function is returning an empty dictionary. I want it to take a list of files open them then return the number of characters as the value and the file name as the key. def fileLengths(files):d = {}files = []for file in