Hi,
I am trying to find the smallest positive number that is divisible by all
of the numbers from 1 to 20 without a remainder. I wrote the following code
(implementation of a solution method found in
http://en.wikipedia.org/wiki/Least_common_multiple#A_method_using_a_table )
but kept getting an
Osemeka Osuagwu wrote:
templist = templist.append(prime)
The append method operates in place, and returns None. It doesn't return a list:
py mylist = []
py x = mylist.append(42)
py x is None
True
py mylist
[42]
Replace that line with just
templist.append(prime)
--
Steven
On 04/07/12 17:01, Osemeka Osuagwu wrote:
lcm = reduce(lambda x, y: x*y, templist) #my first lambda
expression! (multiply all members of templist
Congratulations :-)
But you could have done:
import operator
lcm = reduce(operator.mul, templist)
instead.
--
Alan G
Author of the