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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Youssef Moustahib](https://secure.gravatar.com/avatar/1768f7cccded67c1b223e93e36c716d0?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Youssef Moustahib
7,779 PointsWhy won't this pack?
def new(*args):
total = 0
for thing in args:
total += thing
print(total)
x = (1,2,3)
y = (4,5,6)
new(x,y)
Why won't this pack? Help appreciated.
1 Answer
![Alex Koumparos](https://uploads.teamtreehouse.com/production/profile-photos/8418842/micro_IMG_1256__cropped_and_reduced_res_.jpg)
Alex Koumparos
Python Development Techdegree Student 36,887 PointsHi Youssef,
You've declared x as a tuple (1, 2, 3)
. Also, you've declared y as a tuple (4, 5, 6)
.
Therefore you are passing two arguments into your function, both tuples.
You've declared total as an int (0
).
You can't add a tuple to an int.
What you can do is unpack x and y into their individual elements when you call the function (so in effect you are passing six arguments into your function, all ints):
new(*x, *y)
Hope that helps,
Alex
Youssef Moustahib
7,779 PointsYoussef Moustahib
7,779 PointsThank you!!