Question: Problem Statement: This program separates the letters and digits from a string containing both. For example, the string 'a1pha8' contains the letters 'apha' and the

Problem Statement: This program separates the letters and digits from a string containing both. For example, the string 'a1pha8' contains the letters 'apha' and the digits '18'.

Lab Scenario: The program repeats until the character 'n' is provided as input. The program takes a user input of a string containing both letters and digits. It extracts and separates the letters and digits from the string, adds them to two lists, and displays them.

Consider the following important points:

1) You need to design a user-defined function named extract_letters_and_digits which takes user string as a parameter and returns two lists. One is the list of letters and the other being the list of digits.

a. Hint: Iterate over each character in the user string, check if the character is a letter or a digit. Define two lists and store the letters and digits separately in different lists. You may make use of the isdigit() method as needed.

b. You also need to find a simple docstring for this function.

2) Your program must have a main() function. Function main() designs user menu, should take user input, call the extract_letters_and_digits function, and then prints the lists returned by the function. You need to consider using a 'for' loop for printing both the lists to get full points.

a. No need to find a docstring for the main function

b. Consider a 'while' loop to take user string as long as the user does not provide the character 'n' as the input.

3) A sample I/O is provided below:

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 Programming Questions!