Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Rutendo Chaurura
6,809 PointsThis code i not passing
We have a bunch of prices and sales numbers and we need to find out our total earnings.
Let's start by writing a function named product_sales that takes a single two-member tuple made up of a price and a number of units sold. product_sales should return the product of the price and the number of units.
prices = [
(6.99, 5),
(2.94, 15),
(156.99, 2),
(99.99, 4),
(1.82, 102)
]
def product_sales(price, units):
return price * units
2 Answers

Steven Parker
221,451 PointsThis function takes two individual arguments, but the instructions ask for a function " that takes a single two-member tuple"
So your declaration might look something like:
def product_sales(one_tuple):
And of course, the body would need to be adapted accordingly.

Learn QA
6,011 Pointsdef product_sales(one_tuple): product_sales = 21.0 return product_sales
this code passed but not sure how

Steven Parker
221,451 PointsLooks like you tricked the challenge by guessing the result for the values it tested with.
But a valid solution would use the argument and calculate) the result.
busongomwembe
30,682 Pointsbusongomwembe
30,682 PointsWe have a bunch of prices and sales numbers and we need to find out our total earnings.
Let's start by writing a function named product_sales that takes a single two-member tuple made up of a price and a number of units sold. product_sales should return the product of the price and the number of units.
prices = [ (6.99, 5), (2.94, 15), (156.99, 2), (99.99, 4), (1.82, 102) ] def product_sale(single_two): price,units=single_two return price* units print(reduce(product_sale,prices))
NB why not working too
Steven Parker
221,451 PointsSteven Parker
221,451 PointsTwo issues here: