Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def interlock(word1, word2, x=0):
- #interlocks 2 words and returns the 2 ways of interlocking them as a list of 2 strings.
- returnwords = []
- listi = []
- if len(word1) >= len(word2):
- longerword = len(word1)
- elif len(word1) <= len(word2):
- longerword = len(word2)
- i = 0
- while i < (longerword):
- try:
- listi.append(word1[i])
- listi.append(word2[i])
- except:
- pass
- i += 1
- delimiter = ''
- newword = delimiter.join(listi)
- returnwords.append(newword)
- if x != 1:
- returnwords.append(interlock(word2,word1,1)[0])
- return returnwords
Add Comment
Please, Sign In to add comment