"Emile van Sebille" <[EMAIL PROTECTED]> wrote

yet if i wrote range (1, 500, 2) [1, 3, 5, 7....... ..499] is there a command where i could total that list quickly?


You're looking for sum --
 sum(range (1, 500, 2) )

Or on older Python versions reduce:

import operator
s = reduce(operator.add, range(1,500,2))

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to