我要求用户输入一些文字。我需要找到字符串中最长的单词,连续有两个辅音如果有连续3个辅音成一个词-完成“完成执行”。看来我在鳕鱼中做错了,请帮忙。谢谢!
def filter_(word, g):
x = ''
for i in word:
if i in g:
x += i
else:
x += ' '
for lett in x.split():
if len(lett) >= 2:
return word
return ''
g = ('"bcdfghjklmnpqrstvwxyz"')
result = []
for word in ' the difference between british and american english '.split():
result.append(filter_(word, g))
print(max(result, key=len))
words = input('Abc ab a abcd')
word_list = words.split()
longest_word = max(word_list, key=len)
请尝试