Currently I'm working on this piece of code. It works fine now.
numbers = [1,2,3,4,5,6]
squared_numbers = map(lambda n: n*n, numbers)
# print(list(squared_numbers))
total = reduce(lambda acc, n: n+acc, squared_numbers)
but if I uncomment the print statement it gives me the following error. However if I print squared_numbers the output is still a map object <map object at 0x7f82922750d0>.
total = reduce(lambda acc, n: n+acc, squared_numbers)
TypeError: reduce() of empty sequence with no initial value
Can any one please explain why this is? thanks in advance..