Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Functional Python The Lambda Lambada Reduce

i'm not sure why this is not working

it giving me an error saying couldn't find product_sales()

prices.py
import add 

prices = [
    (6.99, 5),
    (2.94, 15),
    (156.99, 2),
    (99.99, 4),
    (1.82, 102)
]


def product_sales(single_two): 
    price,units=single_two
    return price* units 
    print(reduce(product_sales,prices))

1 Answer

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

Hey there tryston downing !

I think it may be a few things, but I'm not sure exactly what challenge step you're working on. But the reduce import need a little editing and we want to be returning a value instead of printing it. The following code got me up to the last challenge, this should help get you there as well. From there, read the instructions carefully, we'll be wanting to use map , add and creating a new variable. I hope this helps you out

from operator import add
from functools import reduce

prices = [
    (6.99, 5),
    (2.94, 15),
    (156.99, 2),
    (99.99, 4),
    (1.82, 102)
]


def product_sales(a_tuple):
    price, units = a_tuple
    return price * units