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 trialvictor E
19,146 Pointsnot sure why this isn't working.
the example it shows as my output seems correct
# combo([1, 2, 3], 'abc')
# Output:
# [(1, 'a'), (2, 'b'), (3, 'c')]
def combo(item1, item2):
combined = []
for i in range(0, len(item1)):
combined.append((item1[i],item2[1]))
return combined
victor E
19,146 PointsKyrylo, thank you that does work for the desired problem but it does not want me to use zip. this is the message it gives me lol
Bummer: Don't use zip()
! I know it exists but the point of this challenge is to solve the problem yourself.
1 Answer
Steven Parker
231,275 PointsIt looks like you just have a typo. The index for item2 is a 1 (one) instead of the letter "i":
combined.append((item1[i],item2[1])) # original code
combined.append((item1[i],item2[i])) # fixed
Note that the "bummer" message doesn't show your output, but an example of what it is expecting.
Kyrylo Troian
570 PointsKyrylo Troian
570 PointsYou are generating an index with for in, but you use constant 1 as an index from item2. for in loop works with iterable and generator objects, range is a generator function and list is iterable. You can simplify working with lists:
Also, think about renaming variables item1 and item2, item_1and item_2 or numbers and characters will be better.
For your needs, you may use zip():