Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions