L = ['Hello', 'World', 18, 'Apple', None]
#第一种方法
temp = [s.lower() for s in L if isinstance(s,str)]
if temp == ['hello', 'world', 'apple']:
print('测试通过!')
else:
print('测试失败!')
#第二种方法
K=[]
for t in L:
if isinstance(t,str):
K.append(t.lower())
if K == ['hello', 'world', 'apple']:
Sign in to make a reply
落落96897
L = ['Hello', 'World', 18, 'Apple', None]
#第一种方法
temp = [s.lower() for s in L if isinstance(s,str)]
if temp == ['hello', 'world', 'apple']:
print('测试通过!')
else:
print('测试失败!')
#第二种方法
K=[]
for t in L:
if isinstance(t,str):
K.append(t.lower())
if K == ['hello', 'world', 'apple']:
print('测试通过!')
else:
print('测试失败!')