Welcome to the Treehouse Community
Looking to learn something new?
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,822 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