Question: undefined The main function in your program must be named: decode string. It has been provided for you. Copy this function into your program EXACTLY

undefinedundefined The main function in your program must be named: decode string.

The main function in your program must be named: decode string. It has been provided for you. Copy this function into your program EXACTLY as written: def decode string (string, pair print "Original: ", string) swapped pair = swap pair (string, pair) swapped adi = swar..adi (swapped pair) print("Final:", finalize (swapped adi)) . As you can see, decode string calls THREE helper functions namely: swap..pair (string, pair) : pair will consist of two characters. Replace all occurrences of the first character from pair with the second in string. For example, if string were ha 77 y' and pair were '7p', then string would become happy'. Return the corrected string. HINT: string. replace() might help swap adj (string): Remove the last character from string if string does not have an even amount of characters. Then, swap each adjacent character in string once. For example, the string. abed' would swap. a. with. b' and then with 'd' to become, badeThe string. abcde' would have the last character removed before swapping resulting in the same outcome badc'- Return the corrected string. finalize (string Make the following changes to string: a) Strip away all leading and trailing spaces b) Call swar. pair to replace all instances of . z' with a single space. c) Move the last character to the front of the string d) Ensure only the first letter of the string is capitalized e) Add . A+.' to the end of the string For example, the string 'CORE: zs' (two spaces before and after the letters) would produce. score : A+.' after the changes. Return the corrected string. The sample output provided shows three examples. Your output should be similar in layout but reflect whatever strings are passed to the main function. >>> decode_string("f YzbocznarzaezDhtSiYz6oDzSereevazzn i", "6") Original: f Yzbocznarzae zDhtSiYz6oDzSereevazzn i Final: If you can read this you deserve an A+. >>> decode_string("S tz5hzSzaett 5z", "5i") Original: S tz5hzSzaettsz?5z Final: Is this a test? A+. ", "40") >>> decode_string("z ogztn4iz Original: z ogztn4iz Final: I got an A+

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!