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 Python Collections (2016, retired 2019) Tuples Combo

checked independently, but not working here

I am getting errors on this. Don't know why. Compiles independently

combo.py
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]

my_tuple = []
a = [1,2,3]
b = ('abc')

def combo(*args):
   for i in range(len(a)):
       c= (a[i], b[i])
       my_tuple.append(c)

   return my_tuple

combo(a,b)

6 Answers

Steven Parker
Steven Parker
231,269 Points

The challenge tests your work using arguments that are not the same as the examples!

So when constructing the solution:

  • don't use any fixed values, work only with the supplied arguments
  • all code should be part of (inside) the function
  • you only need to define the function, not call it

Ok, I just set everything within the function. But still not working.

def combo():
    a = [1,2,3]
    b = ('abc')
    my_tuple = []
    for i in range(len(a)):
       c = (a[i], b[i])
       my_tuple.append(c)

    return my_tuple

</p>```

"don't use any fixed values, work only with the supplied arguments"
 what are the supplied arguments then?  This specificities of how the compiler operates and what exactly is expected is really horribly explained.
Steven Parker
Steven Parker
231,269 Points

The supplied arguments are the ones you were calling "*args" in your original definition. You can bet that when the challenge tests your function, the arguments it will give it will not be [1, 2, 3] and 'abc'.

The instructions say the function "takes two ordered iterables". Perhaps you would call them "a" and "b"?

so changed to

def combo(a,b):

only error is "bummer: try again." No specifics. This is really unnecessarily mystifying.

Steven Parker
Steven Parker
231,269 Points

When you added the parameters, did you also remove the assignments of the fixed values?

Also, does that stray HTML tag actually appear on the bottom line?

def combo(a,b): my_tuple = [] for i in range(len(a)): c = (a[i], b[i]) my_tuple.append(c) return my_tuple

This is the state of it now. The html tag was me being clever and trying to follow the markdown cheatsheet guidelines. Really, shouldn't *args be sufficient as the argument?

Steven Parker
Steven Parker
231,269 Points

So does it pass now?

And your formatting was good other than that HTML tag. Perhaps you were just looking at an example where the formatting was applied to some HTML? Do use the formatting, Python is impossible to check without it.

And yes, you could code it using *args but it's simpler to just have two parameters.

I work in anaconda, with spider. Formatting is good. the tag was done when positing to you here. This is still not working! error given is "Bummer, try again" Honestly, what kind of error is that? It speaks nothing to the problem. This is really becoming asinine.

Steven Parker
Steven Parker
231,269 Points

Can you show the code (with formatting) that you have now?

def combo(a,b):
    my_tuple = []
    for i in range(len(a)):
       c = (a[i], b[i])
       my_tuple.append(c)

    return my_tuple

</p>

ok, I have no idea how to get rid of last tag. Anyhow you can see the bit of code.

Steven Parker
Steven Parker
231,269 Points

I don't see anything wrong except for that stray HTML paragraph tag.

So I pasted the rest of it directly into the challenge and it passed.

ok thanks, but obviously there is a bug in the system. Is there somebody who can update my profile then?

Steven Parker
Steven Parker
231,269 Points

I don't understand how your profile would be involved, but for system issues you should contact the Support folks.