Discuss / Python / Daily Work

Daily Work

Topic source

无愠无殇

#1 Created at ... [Delete] [Delete and Lock User]

L = ['Hello','World',18,'Apple',None]

M = [ i.lower() for i in L if isinstance(i,str)]

print(M)

[s.lower() if isinstance(s,str) else s for s in L] 看下边的才发现没说让把非字符删掉


  • 1

Reply