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)
![Eddy Hood](https://secure.gravatar.com/avatar/1c2c89f92d50924a782904ac70a91959?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Eddy Hood
10,154 PointsCode works on editor, but not in treehouse...
I'm sure this isn't a very elegant solution, but it's the best I could think of. It works in my editor, but not when I submit to Treehouse. Any thoughts?
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]
def combo(*args):
full_list = []
x_tuple = ()
y_tuple = ()
z_tuple = ()
for items in args:
index_positions = list(enumerate(items))
full_list.extend(index_positions)
for x,y in full_list:
if x == 0:
x_add = x_tuple + (y,)
x_tuple = x_add
elif x == 1:
y_add = y_tuple + (y,)
y_tuple = y_add
elif x == 2:
z_add = z_tuple + (y,)
z_tuple = z_add
full_list = [x_tuple,y_tuple,z_tuple]
return(full_list)
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 Points
Be careful about testing a challenge in an external REPL or IDE.
If you have misunderstood the challenge, it's also very likely that you will misinterpret the results.
In this case, you're making assumptions about the incoming data. Unlike the sample shown in the comments, the real test data may have more than 3 items and the items might not contain sequential numbers.
You'll need to write your function so it can work on iterable pairs of any length and with any contents. The good news is that a generic solution can actually be less complicated and more compact that what you have here.
![Eddy Hood](https://secure.gravatar.com/avatar/1c2c89f92d50924a782904ac70a91959?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Eddy Hood
10,154 PointsYeah, makes sense now. Solved. Thank you, Steven! The answer was so much simpler. :) Took 6 lines of code.
Eddy Hood
10,154 PointsEddy Hood
10,154 PointsThanks Steven. I'll work on it. The instructions said: Assume the iterables will be the same length, which is why I went the route I did. I'll take what you suggest and hammer it out.
Steven Parker
230,688 PointsSteven Parker
230,688 PointsYes, you can assume they are the same length as each other. But not the same length as in the example.