[Tutor] Fwd: Re: Adding consecutive numbers
Alan Gauld
alan.gauld at btinternet.com
Wed May 6 16:20:45 CEST 2015
On 06/05/15 15:01, Dave Angel wrote:
>> def adding_all(x):
>> total = 0
>> for num in x:
>> total +=num
>> return total
>
> Good function.
Except for the fact that the built-in sum() function
does the same thing with a lot less typing...
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list