Re: [Tutor] the products of an element of a list

2015-12-26 Thread Tahir Hafiz
Thanks Steven and Peter, I de-dented and changed the variable name and it works now. Cheers, Tahir On Sat, Dec 26, 2015 at 1:42 PM, Peter Otten <__pete...@web.de> wrote: > Tahir Hafiz wrote: > > > Finally getting round to doing some more python. > > Stuck on a little online exercise: > > "Define

Re: [Tutor] the products of an element of a list

2015-12-26 Thread Peter Otten
Tahir Hafiz wrote: > Finally getting round to doing some more python. > Stuck on a little online exercise: > "Define a function prod(L) which returns the product of the elements in a > list L." > > Let's say L = [1, 2, 3, 4] > > I have done this so far but it's not quite working: > > > > def

Re: [Tutor] the products of an element of a list

2015-12-26 Thread Steven D'Aprano
On Sat, Dec 26, 2015 at 12:59:45PM +, Tahir Hafiz wrote: > Finally getting round to doing some more python. > Stuck on a little online exercise: > "Define a function prod(L) which returns the product of the elements in a > list L." > > Let's say L = [1, 2, 3, 4] > > I have done this so far bu

[Tutor] the products of an element of a list

2015-12-26 Thread Tahir Hafiz
Finally getting round to doing some more python. Stuck on a little online exercise: "Define a function prod(L) which returns the product of the elements in a list L." Let's say L = [1, 2, 3, 4] I have done this so far but it's not quite working: def prod(L): sum = 1 for i in L: