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
"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
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
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