Python code: code I have so far: def print_menu(usr_str: str):     aamenu_options = ['c', 'w', 'f', 'r', 's', 'q']     print('\nMENU')     print('c - Number of non-whitespace characters')     print('w - Number of words')     print('f - Fix capitalization')     print('r - Replace punctuation')     print('s - Shorten spaces')     print('q - Quit\n')     aachoice = input('Choose an option: ').lower()     while aachoice not in aamenu_options:         print('Invalid choice')         aachoice = input('Choose an option:')     if aachoice == 'c':         print('Number of non-whitespace characters:', get_num_of_non_WS_characters(usr_str))     elif aachoice == 'w':         print('Number of words:', get_num_of_words(usr_str))     elif aachoice == 'f':         usr, count = fix_capitalization(usr_str)         print('Number of letters capitalized:', count)         print('Edited text:', usr_str)     elif aachoice == 'r':         usr_str = replaced_punctuation(usr_str)         print('Edited text:', usr_str)     elif aachoice == 's':         usr_str = shorten_space(usr_str)         print('Edited text:', usr_str)     return aachoice, usr_str def get_num_of_non_WS_characters(usr_str:str):     count = len(usr_str.replace('',''))     return count def get_num_of_words(usr_str: str):     num_words = len(usr_str.split())     return num_words def fix_capitalization(usr_str):     count = 0     edited_str = ''     check = False     for i, s in enumerate(usr_str):         if i == 0:             if s.islower():                 count += 1                 edited_str += s.upper()             else:                 edited_str += s             continue         if check:             if s.isspace():                 edited_str +=s             elif s.islower():                 count += 1                 edited_str += s.upper()                 check = False             else:                 check = False                 edited_str += s             if s == '.':                 check = True         return usr_str, count      def replace_punctuation(usr_str: str, **kwargs):     exclamation_count = 0     semicolon_count = 0     result = ''     for i in usr_str:         if i == '!':             i = '.'             exclamation_count += 1         elif i == ';':             i = ','             semicolon_count += 1         result += i     print('Punctuation replaced', exclamation_count)     print('Exclamation Count:', semicolon_count)     return result def shorten_space(usr_str:str):     usr_str = usr_str.strip()     result = ''     prev = False     for i in usr_str:         if i.isspace():             if not prev:                 result += i                 prev = True             else:                 result += i                 prev = False         return result      def main():     usr_str = input('Enter a sample text: \n')     print('\nYou entered:', usr_str)     choice = ''     while choice != 'q':         choice, usr_str = print_menu(usr_str) if __name__ == '__main__':     main() used input in the problem:  we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!  problems: c(whitespace): mine = 221; correct = 181 f(Fix capitalization): mine = 1, correct = 3  s(Shorten spaces): mine = (no output); correct: Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! it tells me to use .isspace()?? I have attatched a picture of my code that did not work. Thank you so much and have a great day

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

Python code:

code I have so far:

def print_menu(usr_str: str):
    aamenu_options = ['c', 'w', 'f', 'r', 's', 'q']
    print('\nMENU')
    print('c - Number of non-whitespace characters')
    print('w - Number of words')
    print('f - Fix capitalization')
    print('r - Replace punctuation')
    print('s - Shorten spaces')
    print('q - Quit\n')

    aachoice = input('Choose an option: ').lower()
    while aachoice not in aamenu_options:
        print('Invalid choice')
        aachoice = input('Choose an option:')
    if aachoice == 'c':
        print('Number of non-whitespace characters:', get_num_of_non_WS_characters(usr_str))
    elif aachoice == 'w':
        print('Number of words:', get_num_of_words(usr_str))
    elif aachoice == 'f':
        usr, count = fix_capitalization(usr_str)
        print('Number of letters capitalized:', count)
        print('Edited text:', usr_str)
    elif aachoice == 'r':
        usr_str = replaced_punctuation(usr_str)
        print('Edited text:', usr_str)
    elif aachoice == 's':
        usr_str = shorten_space(usr_str)
        print('Edited text:', usr_str)
    return aachoice, usr_str


def get_num_of_non_WS_characters(usr_str:str):
    count = len(usr_str.replace('',''))
    return count

def get_num_of_words(usr_str: str):
    num_words = len(usr_str.split())
    return num_words
def fix_capitalization(usr_str):
    count = 0
    edited_str = ''
    check = False
    for i, s in enumerate(usr_str):
        if i == 0:
            if s.islower():
                count += 1
                edited_str += s.upper()
            else:
                edited_str += s
            continue
        if check:
            if s.isspace():
                edited_str +=s
            elif s.islower():
                count += 1
                edited_str += s.upper()
                check = False
            else:
                check = False
                edited_str += s
            if s == '.':
                check = True
        return usr_str, count
    
def replace_punctuation(usr_str: str, **kwargs):
    exclamation_count = 0
    semicolon_count = 0
    result = ''
    for i in usr_str:
        if i == '!':
            i = '.'
            exclamation_count += 1
        elif i == ';':
            i = ','
            semicolon_count += 1
        result += i
    print('Punctuation replaced', exclamation_count)
    print('Exclamation Count:', semicolon_count)
    return result

def shorten_space(usr_str:str):
    usr_str = usr_str.strip()
    result = ''
    prev = False
    for i in usr_str:
        if i.isspace():
            if not prev:
                result += i
                prev = True
            else:
                result += i
                prev = False
        return result
    
def main():
    usr_str = input('Enter a sample text: \n')
    print('\nYou entered:', usr_str)
    choice = ''
    while choice != 'q':
        choice, usr_str = print_menu(usr_str)

if __name__ == '__main__':
    main()

used input in the problem: 

we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! 

problems:

c(whitespace): mine = 221; correct = 181

f(Fix capitalization): mine = 1, correct = 3 

s(Shorten spaces): mine = (no output); correct: Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!

it tells me to use .isspace()??

I have attatched a picture of my code that did not work.

Thank you so much and have a great day

Choose an option: c
Number of non-whitespace characters: 228
MENU
с
f
I
S
q Quit
Number of non-whitespace characters
Number of words
Fix capitalization
-
Choose an option: f
Number of letters capitalized: 0
Edited text: Edited text: we'll continue our quest in space. there will be more
shuttle flights and more shuttle crews and, yes; more volunteers, more civilians
, more teachers in space. nothing ends here; our hopes and our journeys continue
!
Replace punctuation
Shorten spaces
MENU
S
q
с
Number of non-whitespace characters
W Number of words
f - Fix capitalization
r Replace punctuation
Shorten spaces
Quit
с
W
f
I
S
q
Choose an option: s
Edited text:
MENU
Number of non-whitespace characters
Number of words
Fix capitalization
Replace punctuation
Shorten spaces
Quit
Transcribed Image Text:Choose an option: c Number of non-whitespace characters: 228 MENU с f I S q Quit Number of non-whitespace characters Number of words Fix capitalization - Choose an option: f Number of letters capitalized: 0 Edited text: Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians , more teachers in space. nothing ends here; our hopes and our journeys continue ! Replace punctuation Shorten spaces MENU S q с Number of non-whitespace characters W Number of words f - Fix capitalization r Replace punctuation Shorten spaces Quit с W f I S q Choose an option: s Edited text: MENU Number of non-whitespace characters Number of words Fix capitalization Replace punctuation Shorten spaces Quit
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
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.
Similar questions
  • SEE MORE QUESTIONS
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