Discuss / Python / 交作业

交作业

Topic source

请修改列表生成式,通过添加if语句保证列表生成式能正确地执行:

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


  • 1

Reply