On 9 May 2013 07:32, Noufal Ibrahim <nou...@nibrahim.net.in> wrote: > Gora Mohanty <g...@mimirtech.com> writes: > >> On 8 May 2013 23:00, Jagadeesh N. Malakannavar <mnjagade...@gmail.com> wrote: >>> I prefer to do it like this >>> >>>>>> a = list(str(3245325)) >>>>>> sum(map(int, a)) >>> 24 >> >> What does the map() gain you over basic list comprehension: >> sum( [int(i) for i in '3245325'] ) > > You could drop the []. No need to first generate and then iterate over > the list.
Ah, yes! Forgot that the expression would act as a generator. Good catch! Regards, Gora _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers