Discuss / Python / 作业

作业

Topic source

Statby

#1 Created at ... [Delete] [Delete and Lock User]
#!/bin/env python3
#coding=utf-8

L = ['Hello', 'World', 18, 'Apple',None]
#print ( "L =" ,L )

L2 = [i.lower() for i in L if isinstance(i,str)]
#因为字符已经是True 所以可以免去 一个boolean判断?

print (L2)

  • 1

Reply