Creating variables on the fly...
Aahz Maruch
aahz at netcom.com
Tue Apr 4 16:27:26 EDT 2000
In article <gl6G4.2926$HG1.87612 at nnrp1.uunet.ca>,
Warren Postma <embed at geocities.com> wrote:
>
>def Sum(dict):
> n = 0
> for i in dict.keys():
> n = n + dict[i]
> return n
I think you mean:
def Sum(dict):
n = 0
for i in dict.values():
n = n + i
return n
This should be faster.
--
--- Aahz (Copyright 2000 by aahz at netcom.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
"It's 106 miles to Chicago. We have a full tank of gas, a half-pack of
cigarettes, it's dark, and we're wearing sunglasses." "Hit it."
More information about the Python-list
mailing list