python学习笔记:列表生成器
提问:请修改列表生成式,通过添加if语句保证列表生成式能正确地执行:
L1 = [‘Hello’, ‘World’, 18, ‘Apple’, None]
回答:L1=[‘Hello’, ‘World’, 18, ‘Apple’, None]
L2=[]
for i in L1:
if isinstance(i,str)==True:
L2.append(i)
L2=[s.lower() for s in L2]

最后
以上就是超级店员最近收集整理的关于python学习笔记:列表生成器的全部内容,更多相关python学习笔记内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复