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!
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
I want some help for this challenge
Ok, so for this challenge I try to make a mix between to iterables. I tried many things but this code is the most logical for me to output something like the example. The problem now is when I try this code on my computer it appears that the index is out of range. I don't know the reason for this error. The code appears logical to me.
# combo([1, 2, 3], 'abc') # Output: # [(1, 'a'), (2, 'b'), (3, 'c')] def combo(nums,strings): new_list=  index = 0 for num in nums: for string in strings: if string[index] == string: new_list.append((num,string)) index = index + 1 return new_list
Dave StSomeWhere19,870 Points
Yes your code is logical but as the error says index is out of range
if string[index] == string:
What is the valid index range for
Can you be more explicit please. In the line of code which you copied, i want a statement which is always true but i don't know the length of the string itself