Write a Python program that will take one input made up of two strings separated by a comma and a space (see samples below). Then create a mixed string with alternative characters from each string. Any leftover chars will be appended at the end of the resulting string. Hint: For adding the leftover characters you may use string slicing. Note: Please do not use lists for this task. ===================================================================== Sample Input 1: ABCD, efgh Sample Output 1: AeBfCgDh Explanation: At first, the two strings divided by ", " should be separated. Then the first character of the first string 'A' is concatenated with the first character of the second string 'e' which in turn is concatenated to the second character of the first string 'B', the second character of the second string f and so on since the strings are of equal length. ===================================================================== Sample Input 2: ABCDENDFGH, ijkl Sample Output 2: AiBjCkDlENDFGH Explanation: Here, since the length of the first string is greater than the length of the second string, after separation, the characters are concatenated alternatively as in sample input/output 1, till the length of the second string i.e. ijkl. Since, there are no more characters in the second string after that, the remaining characters if the first string i.e. ENDFGH in this case are concatenated at the end of the final string. ===================================================================== Sample Input 3: ijkl, ABCDENDFGH Sample Output 3: iAjBkClDENDFGH Explanation: This time, the length of the second string is greater than the length of the first string therefore the first letters of the 2 strings 'i' and 'A', then the second letters 'j' and 'B' and so on are being concatenated until there are no more letters in the first shorter string following which the remaining letters i.e. ENDFGH again in this case too (this may be different for other different string inputs) are added at the end giving us the resulting output string. ===================================================================== Hint: you can use index() in this task. e.g. str = "abc-de", str.index("-") will return the index of "-", which is 3 in this case. #assign the result string to variable "out_str" def task12(in_str):   # YOUR CODE HERE      return out_str

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a Python program that will take one input made up of two strings separated by a comma and a space (see samples below). Then create a mixed string with alternative characters from each string. Any leftover chars will be appended at the end of the resulting string.

Hint: For adding the leftover characters you may use string slicing.

Note: Please do not use lists for this task.

=====================================================================

Sample Input 1:
ABCD, efgh

Sample Output 1:
AeBfCgDh

Explanation: At first, the two strings divided by ", " should be separated. Then the first character of the first string 'A' is concatenated with the first character of the second string 'e' which in turn is concatenated to the second character of the first string 'B', the second character of the second string f and so on since the strings are of equal length.

=====================================================================

Sample Input 2:
ABCDENDFGH, ijkl

Sample Output 2:
AiBjCkDlENDFGH

Explanation: Here, since the length of the first string is greater than the length of the second string, after separation, the characters are concatenated alternatively as in sample input/output 1, till the length of the second string i.e. ijkl. Since, there are no more characters in the second string after that, the remaining characters if the first string i.e. ENDFGH in this case are concatenated at the end of the final string.

=====================================================================

Sample Input 3:
ijkl, ABCDENDFGH

Sample Output 3:
iAjBkClDENDFGH

Explanation: This time, the length of the second string is greater than the length of the first string therefore the first letters of the 2 strings 'i' and 'A', then the second letters 'j' and 'B' and so on are being concatenated until there are no more letters in the first shorter string following which the remaining letters i.e. ENDFGH again in this case too (this may be different for other different string inputs) are added at the end giving us the resulting output string.

=====================================================================

Hint: you can use index() in this task. e.g. str = "abc-de", str.index("-") will return the index of "-", which is 3 in this case.

#assign the result string to variable "out_str"
def task12(in_str):
  # YOUR CODE HERE
  
  return out_str
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education