查找字符串中连续两个辅音的最大单词

问题描述 投票:-2回答:1

我要求用户输入一些文字。我需要找到字符串中最长的单词,连续有两个辅音如果有连续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))
python
1个回答
-1
投票
words = input('Abc ab a abcd')  
word_list = words.split() 
longest_word =  max(word_list, key=len)

请尝试

© www.soinside.com 2019 - 2024. All rights reserved.