Help with reduce().
grayson-wilson at home.com
Tue Jul 10 01:53:35 CEST 2001
Ok well I have ANOTHER problem with one of the examples in my book (By The
Way, "Teach yourself python in 24 hours" is an extremely poorly written book
and I do not reccomend it to any newbies who are just starting off)
any ways the example is as follows.
n = range(1,11)
return x * y
f = reduce(mult,n)
I get everything up to reduce. I relize mult() takes the first two numbers
in range N which would be 1, 2 and multiplys them together to get 2... ok
fine im good ... now comes the tricky part!! what does reduce do? Does it
take the whole range and make it into a number (12345678910) then subtract 2
(the result of the function mult) or what does it do.
And i have another question (not related to first question)
x = ['Thu', 'Aug', '5', '06:06:27', 'MDT', '1999']
return x + ' ' + y
r = reduce(strp,x)
my problem is this line return "x + ' ' + y" what does it return the value
of. I would understand it if it was x + y but the qutation marks are what
throw me off what do they mean?
More information about the Python-list