Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def weave(str1, str2, wString='', i=0):
- weavedString=wString
- if str1 == "" or str2 == "":
- #If either is empty, it returns empty
- return ""
- if len(str1) == i:
- #If the first string has no more room, it adds the rest
- #of the second to the weave
- weavedString=weavedString+str2[i:]
- return weavedString
- if len(str2) == i:
- #Same as above, but the other way around
- weavedString=weavedString+str1[i:]
- return weavedString
- weavedString=weavedString+str1[i]+str2[i]
- weave(str1, str2, weavedString)
- weave("Hello", "Shalom")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement