任务要求:定义函数,接收一个列表作为参数,找出传入的列表中长度大于5的元素,添加到新列表中并返回
知识点:函数、列表、for循环、if判断、len()函数
参考答案:
# coding=utf-8
"""
Author: 笨笨
Date: 2020-12-21
"""
def len_five(L):
new_list = []
for i in L:
if(len(i)>5):
new_list.append(i)
return new_list
L = ["C/C++", "Python", "Vue", "Django", "flask", "LoadRunner", "MySQL", "MongoDB", "Redis", "Java", "JMeter"]
NL = len_five(L)
print(NL)