Answer to Question #288709 in Python for Aloxord

Question #288709

A program is asked to execute a text that is given as a multi-line string, and then returns statistics on the frequency of characters and word usage in the text based on the following specification. a) Create the auxiliary function capitalize_keep_only_en_chars (word) which accepts a word at the input and returns it in capital letters after ignoring characters other than the English alphabet (punctuation, etc.). For example, to enter "one--" return the word "ONE".

1
Expert's answer
2022-01-19T12:56:44-0500
# Python3 program to put spaces between words 
# starting with capital letters.

# Function to amend the sentence
def amendSentence(string):
    string = list(string)

    # Traverse the string
    for i in range(len(string)):

        # Convert to lowercase if its
        # an uppercase character
        if string[i] >= 'A' and string[i] <= 'Z':
            string[i] = chr(ord(string[i]) + 32)

            # Print space before it
            # if its an uppercase character
            if i != 0:
                print(" ", end = "")

            # Print the character
            print(string[i], end = "")

        # if lowercase character
        # then just print
        else:
            print(string[i], end = "")

# Driver Code
if __name__ == "__main__":
    string = "BruceWayneIsBatman"
    amendSentence(string)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS