Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

URGENT! THANK YOU! 2. Write a function weave(s1, s2) that takes as inputs two strings s1 and s2 and uses a loop to construct and

URGENT! THANK YOU!

image text in transcribedimage text in transcribed

2. Write a function weave(s1, s2) that takes as inputs two strings s1 and s2 and uses a loop to construct and return a new string that is formed by "weaving" together the characters in the strings s1 and s2 to create a single string. In other words, the new string should alternate characters from the two strings: the first character from s1, followed by the first character from s2, followed by the second character from s1, followed by the second character from s2, etc. 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 new string >>weaveC' aaaaaa', "bbbbbb'") abababababab >weave('abcde', 'VWXYZ aVbWcXdYeZ >>> weave(' aaaaaa', 'bb') # four extra 'a' characters at the end ababaaaa >>> weave(' aaaa', 'bbbbbb') # two extra 'b' characters at the end ababababbb >>>weave( aaaa', '") # all of the 'a' characters are extra! weave ', bbbb') # all of the 'b' characters are extra! weave(', '' You solved this problem using recursion in [Problem Set 2][ps2], but for this problem set you must use a loop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago

Question

How could assessment be used in an employee development program?

Answered: 1 week ago