This Python function interlocks the characters of two words (e.g., "sho" + "col" -> "school"). word1-char1 + word2-char1 + word1-char2 + ...
def interlock(a,b):
i = 0
c = ""
d = ""
while (i < len(a) and len(b)):
c = (a[i]+b[i])
d = d + c
i+=1
return(d)
interlock("sho", "col")
Now, I would like to apply this function to a list of words. The goal is to find out any interlock corresponds to an item of a list.
word_list = ["test", "col", "tele", "school", "tel", "sho", "aye"]
To do that, I would first have to create a new list that has all the interlocks in it. This is exactly where I am stuck - I don't know how to iterate over word_list using interlock.
Thanks for your help!
i < len(a) and len(b)means(i < len(a)) and len(b)test-colandcol-testvalid pairings or do you only pair once?