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 trialCalvin Hoag
8,515 PointsUnhelpful error feedback
Challenge Task 1 of 4 says "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." - I don't know if I have the answer or not but neither the video, or the error feedback is being helpful. I don't understand where the error "Bummer! product_sales threw an exception when given the argument (10.5, 2)"
prices = [
(6.99, 5),
(2.94, 15),
(156.99, 2),
(99.99, 4),
(1.82, 102)
]
def product_sales(x, y):
return x * y
1 Answer
Steven Parker
231,269 PointsThose "bummer" messages aren't always helpful.
So here's some hints:
- the challenge says the function should take a single argument (yours currently takes two).
- the argument will be a two-member tuple, so you will subscript it to get the 2 values
- subscripting is done with brackets ("
[]
") - the indexes of tuple members starts with 0
Calvin Hoag
8,515 PointsCalvin Hoag
8,515 PointsThank you!
Where does it get the argument (10.5, 2)? Is that a built in test happening behind the scenes?