Question: in python write a recursive method called def weave(str1, str2).This method should return the string that is formed by weaving together the characters in the

in python write a recursive method called def weave(str1, str2).This method should return the string that is formed by "weaving" together the characters in the strings str1 and str2 to create a single string. For example:

  • weave("aaaa", "bbbb") should return the string "abababab"
  • weave("hello", "world") should return the string "hweolrllod" If one of the strings is longer than the other, its "extra" characters the ones with no counterparts in the shorter string should appear immediately after the "woven" characters (if any) in the returned string. For example, weave("recurse", "NOW") should return the string "rNeOcWurse", in which the extra characters from the first string the characters in "urse" come after the characters that have been woven together. This method should not do any printing; it should simply return the resulting string. If None is passed in for either parameter, the method should print "Illegal Argument". If the empty string ("") is passed in for either string, the method should return the other string. For example, weave("hello", "") should return "hello" and weave("", "") should return "".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!