The following lower case letters are written partly below the baseline: g, j, p, q, y. We say that these letters have a descender.
Write a function named hasDescender() that returns a list of those words in a string in which at least one letter has a descender.
A word should appear in the return list at most once, no matter how many letters in it have descenders and no matter how many times the word occurs in the input string.
You may assume that the input string consists of only lower case letters and spaces – no punctuation or upper case letters. The order of words in the returned list does not matter.
Input: a string s that consists of words, separated by spaces Return: a list of words in s that contain at least one descender
For example, the following would be correct output:
will = 'suspicion always haunts the guilty mind'
print(hasDescender(will))
['suspicion', 'always', 'guilty']
def hasDescender(text, letter):
list = []
will = text.split()
for word in will:
if word not in result and letter in word:
list.append(word)
return list
will = "suspicion always haunts the guilty mind"
baseline = "g"
print(hasDescender(will, baseline))
output:
['guilty']
but I want my output to be ['suspicion', 'always', 'guilty']
Please help me with this code. I would be very appriciated.