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 trialDan Craciunescu
5,503 PointsIs there a *args equivalent for variables when number of args is unknown?
Hi, I understand from the video that unpacking is strict and I played with it in the workspace and got the errors when adding/removing a valX and so on. Unpacking as presented works fine if you know how many items are returned by the function. But what if my function takes and returns an unknown number of items, like from user input, and I want to unpack those into variables? All I can think of is a for loop on the tuple with string concatenation adding the next index number to 'val' in order to create a new 'valN' name and add it to a list, then use the newly created list of variable names for unpacking. Would this work? Is there an easier way to do it, like *args?