How do I sum all occurrences of a number in a file?
I have a file with a bunch of numbers, each on it's own line:
5
3
11
3
7
3
5
5
11
7
7
...
How do i sum them up so that the output will be ,
5 : 15
3 : 9
11: 22
7 : 21
___
Tutor maillist
ry, I just don't know how to write a code to count the number of divisors
From: David Hutto
To: masawudu bature
Cc: tutor@python.org
Sent: Mon, September 27, 2010 11:36:05 PM
Subject: Re: [Tutor] Python Help
On Tue, Sep 28, 2010 at 12:15 AM, masawudu batur
I'm having a hard time finding the count of divisors that are even. Help
anybody?
Here's my code.
The output is suppose to count the number of even divisors the range has.
def evenCount(b) :
for n in range(x, y+1) :
count = 0
if n % 2 == 0 :
count += n/3