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.

Python Functions, Packing, and Unpacking Packing and Unpacking Unpacking Challenge

I'm having an issue with unpacking.

Edit the variable assignment under the provided function so that the tuple returned from the function call is unpacked into 2 variables, val1, val2

unpacking.py
def unpacker(*args):
    return args

val = unpacker('Python', 'rocks!')

firstly, try rewatching the 2 shorts videos before this, but anyway just try to do something, put some effort into this, you wont learn anything if you just copy the answers, go ahead give it a try then if you still dont get it post again here for an explanation or a guide on how to do it

2 Answers

Steven Parker
Steven Parker
210,850 Points

A cool feature of Python not found in most languages is the ability to assign more than one variable at a time. So when the instructions say the return from the function should be "unpacked into 2 variables", they just mean to list both variables on the left side of the assignment:

val1, val2 = unpacker('Python', 'rocks!')

Were you born this rude or did you come by it over time. I have tried this problem and watched the videos a few time. That's why I posted for help. Next time you decide to be rude don't bother posting.

Rude ??? What for telling you to try to do something, Anyways im sorry if I offended you and good luck in learning

Abdulraheeem Bakare
Abdulraheeem Bakare
4,020 Points

Lol ok Karen, btw do you wanna see the manager cause he isn't in right now :)