Ask Question
13 January, 18:46

Write a program to accept a one-line string (maximum of 100 characters) from the keyboard. Edit the string entered in Part 1a (with code that you write) to remove all the white space, digits, punctuation, and other special characters, leaving only the letters. Print out the resulting compressed string to the screen.

+3
Answers (1)
  1. 13 January, 20:47
    0
    w = str (input ("input your values: "))

    values = ' '. join (filter (str. isalpha, w))

    while len (w) < 100:

    print (values)

    break

    Explanation:

    The code is written in python

    w = str (input ("input your values: "))

    This code ask the user to input any string values with characters, numbers, line spaces, letters etc.

    values = ' '. join (filter (str. isalpha, w))

    This code filters the inputted value to bring only letters. All the letter are then joined together

    while len (w) < 100:

    The code check if the inputted value is less than 100 characters. While it is less than 100 characters. If it is less than 100 character the next code will function.

    print (values)

    This code prints the joined letters after checking with a while loop to confirm the length of character is less than 100

    break

    The break function breaks the code whether it print the values or not.

    Generally, the letters will only be printed if the character inputted is less than 100 and later break the while loop or will not print any letter if the character is greater than 100 and later break.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program to accept a one-line string (maximum of 100 characters) from the keyboard. Edit the string entered in Part 1a (with code ...” in 📘 Engineering if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers