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.
def unpacker(val1, val2): return val1 + " " + val2 val = unpacker('Python', 'rocks!') print(val1) print(val2)
You have set
val2 as parameters in your function, but they haven't been defined outside the function. This will give a NameError when you try to print their values.
The challenge wants you to edit the variable assignment. You don't need to modify the function or the function call. The provided function returns a tuple.
If you have a tuple such as
("Python", "Rocks"), you can use it to assign values to multiple variables at once using the form
val1, val2 = ("Python", "Rocks") as long as the number of variables that you are assigning values to is equal to the size of the tuple that you are getting the values from.
Victor Curtis Jr5,268 Points
If I could give you one word for this code challenge: simplify. You kinda went overboard on this by changing the return value to
val1 + " " + val2. You don't need to do that. Everything can basically be kept the same. Go back and look at the video for how the instructor called two variables. It might make a lot more sense then. Hint:
val = unpacker('Python', 'rocks!') this is still only calling one variable. How do you call two?