224k views
20 votes
g Write a program that reads a list of words, and a character. The output of the program is every word in the list of words that contains the character at least once. For coding simplicity, follow each output word by a comma, even the last one. Assume at least one word in the list will contain the given character. The number of input words is always less than and equal to 10. If the user enters more than 10 words before the character, the program will output Too many words and exit.

User Hemali
by
4.1k points

1 Answer

12 votes

Answer:

Here you go, alter this as you see fit :)

Step-by-step explanation:

array = []

cnt = 0

while cnt < 11:

x = input("Enter a word: ")

array.append(x)

cnt += 1

y = input("Add another word?(Y/n): ")

if y.lower() == "n":

break

letter = input("\\Choose a letter: ")

if len(letter) != 1:

print("Error: too many characters")

quit()

for n in range(len(array)):

if letter.lower() in array[n].lower():

print(array[n], end= ",")

User Rokhaya
by
4.4k points