Question

Python Implement a program that requests from the user a list of words (i.e., strings) and...

Python

Implement a program that requests from the user a list of words (i.e., strings) and then prints on the screen, one per line, all four-letter strings in the list.

>>> Enter word list: ['stop', 'desktop', 'top', 'post']

stop

post

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

#input a list of words

input_string = input("Enter word list: ")

input_string = input_string.split(",")

print("Printing all words of length 4:")

for word in input_string:

word = word.replace('"', '')

word = word.replace("'", '')

word = word.replace('[', '')

word = word.replace(']', '')

word = word.replace(' ', '')

#check words of length 4

if len(word)==4:

print(word)

Output:

Please give thumbsup, if you like it. Thanks.

Add a comment
Know the answer?
Add Answer to:
Python Implement a program that requests from the user a list of words (i.e., strings) and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Implement a program that requests from the user a list of words (i.e., strings) and then...

    Implement a program that requests from the user a list of words (i.e., strings) and then prints on the screen, one per line, all four-letter strings in the list. >>> Enter word list: ['stop', 'desktop', 'top', 'post'] stop post An acronym is a word formed by taking the first letters of the words in a phrase and then making a word from them. For example, RAM is an acronym for random access memory. Write a function acronym() that takes a...

  • Solve in Python 3: Implement function four_letter() that takes as input a list of words (i.e.,...

    Solve in Python 3: Implement function four_letter() that takes as input a list of words (i.e., strings) and returns the sublist of all four letter words in the list. >>> four_letter(['dog', 'letter', 'stop', 'door', 'bus', 'dust']) ['stop', 'door', 'dust']

  • Python Programming Q.3) Write a program that repeatedly asks the user to enter words until they...

    Python Programming Q.3) Write a program that repeatedly asks the user to enter words until they enter a period ("."). Your program should then print all of the words they entered including the period) on a single line separated by spaces. For example, Enter some words (. to stop): > hello > world hello world.

  • ** Language Used : Python ** PART 2 : Create a list of unique words This...

    ** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...

  • It's in Python 3. Please make sure it displays correct strings lenght And displays correct character...

    It's in Python 3. Please make sure it displays correct strings lenght And displays correct character lenght 1 def sum list(numbers): Sums a list of integers param numbers: a list of intege rs return: the sum of the integers in numbe rs def get_string_lengths (st rings) : 10 11 Given a list of strings, return a list of intege rs representing the lengths of the input strings :param strings: a list of strings return: a list of integers represent ing...

  • Write a Python program to read lines of text from a file. For each word (i.e,...

    Write a Python program to read lines of text from a file. For each word (i.e, a group of characters separated by one or more whitespace characters), keep track of how many times that word appears in the file. In the end, print out the top twenty counts and the corresponding words for each count. Print each value and the corresponding words, in alphabetical order, on one line. Print this in reverse sorted order by word count. You can assume...

  • 1. Write a program to input a list of names (strings) from the user and store...

    1. Write a program to input a list of names (strings) from the user and store them in an ArrayList. The input can be terminated by entering the empty string or by entering the string “quit”. 2. Add further functionality to your program so that it searches the ArrayList to find the first string and the last string according to dictionary ordering and then prints out these strings (names). Do this exercise without sorting the names in the ArrayList. For...

  • Simple Python Program Working with strings Write a Python program to read in a number of...

    Simple Python Program Working with strings Write a Python program to read in a number of strings from the user. Stop when the user enters “Done”. Then check if each of the strings contains all the letters of the alphabet. Print the results in the form of a dictionary, where they keys are the strings and the values are the Truth Value for the string, which you just calculated. Sample Run: Enter the strings: taco cat The quick brown fox...

  • using python to Design and implement an application that reads a word from the user and...

    using python to Design and implement an application that reads a word from the user and prints the characters of each word backwards. Use a stack to reverse the characters of each word. What is the difference between a queue and a stack?

  • create a python program that requests input from the user for a starting and ending value....

    create a python program that requests input from the user for a starting and ending value. then your program should return all prime numbers between those two values. you will be using input, conditional and control flow statements

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT