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 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!')
Eldin Guzin
Eldin Guzin
6,010 Points

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
231,269 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.

Eldin Guzin
Eldin Guzin
6,010 Points

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 :)