python 获取列表大于指定长度的元素

 

def long_words(n, str):  
    word_len = []  
    txt = str.split(" ")  
    for x in txt:  
        if len(x) > n:  
            word_len.append(x)  
    return word_len   
print(long_words(3, "The quick brown fox jumps over the lazy dog"))

 

posted @ 2018-11-16 10:33  anobscureretreat  阅读(1675)  评论(0)    收藏  举报