Ask Question
18 May, 01:33

7.12 LAB: Contains the character

Write a program that reads a character, then reads in a list of words. The output of the program is every word in the list that contains the

character at least once. Assume at least one word in the list will contain the given character.

Ex: If the input is:

hello Zoo sleep drizzle

the output is:

zoo

drizzle

Keep in mind that the character 'a' is not equal to the character "A".

+1
Answers (2)
  1. 18 May, 01:56
    0
    The solution code is written in Python 3

    input_char = input ("Enter a character: ") sentence = input ("Enter a sentence: ") word_list = sentence. split (" ") for word in word_list: for c in word: if (c = = input_char) : print (word) break

    Explanation:

    Firstly, use the input function to get a input character and sentence from user (Line 1 - 2)

    Next, use the split method to divide the sentence into a list of individual words using single space as the delimiter (Line 4).

    Create an outer for loop to traverse each word in the word_list and create another inner loop to traverse each character in the word and check if there is any character match with the input character. If so print the word and terminate the inner loop and proceed to the next round of the outer loop.

    After finishing the loop, all the relevant words will be printed.
  2. 18 May, 05:12
    0
    Answer:there is Java program and C+ + program
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “7.12 LAB: Contains the character Write a program that reads a character, then reads in a list of words. The output of the program is every ...” in 📙 Computers & Technology 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