[Tutor] Adding consecutive numbers

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Apr 27 14:58:51 CEST 2015


On 27/04/2015 13:41, Dave Angel wrote:
> On 04/27/2015 06:37 AM, Whom Isac wrote:
>
> But if you really have to do the sum, then you need to build a list, and
> sum it.  That's not very hard either, since range() returns a list, and
> the sum() function is built-in.
>

range() only returns a list in Python 2 but it doesn't matter here as 
sum() accepts any iterable, not just a list.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list