Discuss / Python / 作业

作业

Topic source

阿山Zzz

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

L1 = ['Hello', 'World', 18, 'Apple', None] L2=[] for x in L1: if isinstance(x, str)==1: L2.append(x.lower())
print(L2)

阿山Zzz

#2 Created at ... [Delete] [Delete and Lock User]
L2=[x.lower() for x in L1 if isinstance(x, str)]

  • 1

Reply