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 trialMatthew Byrne
1,920 PointsCombo
When I run this code in Workspaces it gives me back separate lists each containing a tuple. am I at least on the right track? Any help would be great, thanks.
def combo(iterable1, iterable2):
index = 0
while index < len(iterable1) and index < len(iterable2):
letter1 = iterable1[index]
letter2 = iterable2[index]
index = index + 1
tup = (letter1, letter2)
my_list = []
my_list.append(tup)
return my_list
2 Answers
Oszkár Fehér
Treehouse Project ReviewerHi Matthew, Actually the code contains everything to pass the challenge just one indentation and a variable definition
def combo(iterable1, iterable2):
index = 0
while index < len(iterable1) and index < len(iterable2):
letter1 = iterable1[index]
letter2 = iterable2[index]
index = index + 1 <<---here
tup = (letter1, letter2)
my_list = [] <<--- this variable it should be defined outside of while loop
my_list.append(tup)
return my_list <<--- the indentation, it should be in the same column with the while loop, outside of the loop
def combo(iterable1, iterable2):
index = 0
my_list = []
while index < len(iterable1) and index < len(iterable2):
letter1 = iterable1[index]
letter2 = iterable2[index]
index += 1
tup = (letter1, letter2)
my_list.append(tup)
return my_list
Keep up the good work. Happy coding
Matthew Byrne
1,920 PointsThanks Oszkár, that helps a lot :)