为什么我总是想出这么笨这么冗长的程序……( _ _)ノ|扶墙
# -*- coding: utf-8 -*- def f(L): N=[] for n in L: if isinstance(n,str): N.append(n.lower()) else: N.append(n) print(N) L1 = ['Hello', 'World', 18, 'Apple', None] L2=f(L1)
```[s.lower() for s in L1 if isinstance(s,str)]
```
else 那个语句应该不要吧
你的函数还应该return N这样L2才能是一个list,不然为None
Sign in to make a reply
我会掏鸟蛋啊
为什么我总是想出这么笨这么冗长的程序……( _ _)ノ|扶墙