Guest User

Untitled

a guest
Oct 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. def interlock(word1, word2, x=0):
  2. #interlocks 2 words and returns the 2 ways of interlocking them as a list of 2 strings.
  3. returnwords = []
  4. listi = []
  5. if len(word1) >= len(word2):
  6. longerword = len(word1)
  7. elif len(word1) <= len(word2):
  8. longerword = len(word2)
  9. i = 0
  10. while i < (longerword):
  11. try:
  12. listi.append(word1[i])
  13. listi.append(word2[i])
  14. except:
  15. pass
  16. i += 1
  17. delimiter = ''
  18. newword = delimiter.join(listi)
  19. returnwords.append(newword)
  20. if x != 1:
  21. returnwords.append(interlock(word2,word1,1)[0])
  22. return returnwords
Add Comment
Please, Sign In to add comment