Ask Question
24 October, 15:02

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.

+4
Answers (1)
  1. 24 October, 17:53
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers