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 trialsrav
Courses Plus Student 3,476 PointsTo return a list of tuples from 2 iterables given to a function
I am getting the following error: TypeError: sequence item 0: expected str instance, int found
I executed the same code in work spaces and it didn't thrown any error. Also, the returned list was same as expected. Am I missing some thing to solve this challenge ?? Any help is appreciated !!
Alexander Davison
65,469 PointsPlease post your code.
Remember to provide Markdown provided by the markdown cheatsheet below the answer box
srav
Courses Plus Student 3,476 PointsHi, here is my function:
def combo(iter1, iter2):
myList = []
count = 0
for i in iter1:
myList.append((i,"".join(iter2[count:count+1])))
count +=1
return myList
2 Answers
Alexander Davison
65,469 Pointsdef combo(iter1, iter2):
myList = []
count = 0
for i in iter1:
myList.append((i, iter2[count]))
count += 1
return myList
There's no need to use ''.join()
or slicing.
Fergus Clare
12,120 PointsWhat about this solution?
def my_funx(x,y):
new_list = []
for i in range(len(x)):
new_list.append((x[i], y[i]))
return new_list
Alexander Davison
65,469 PointsThat works too. (I also find your answer a little easier to read! )
Timothy Long
Front End Web Development Techdegree Student 6,833 PointsTimothy Long
Front End Web Development Techdegree Student 6,833 PointsCan you post your code?? It will be a little easier to help if you do.