Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. def weave(str1, str2, wString='', i=0):
  2. weavedString=wString
  3. if str1 == "" or str2 == "":
  4. #If either is empty, it returns empty
  5. return ""
  6. if len(str1) == i:
  7. #If the first string has no more room, it adds the rest
  8. #of the second to the weave
  9. weavedString=weavedString+str2[i:]
  10. return weavedString
  11. if len(str2) == i:
  12. #Same as above, but the other way around
  13. weavedString=weavedString+str1[i:]
  14. return weavedString
  15. weavedString=weavedString+str1[i]+str2[i]
  16. weave(str1, str2, weavedString)
  17.  
  18. weave("Hello", "Shalom")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement