Discuss / Python / 作业作业

作业作业

Topic source
# !/usr/bin/env python3
# --coding:utf-8--
l = ['Hello', 'World', 18, 'Apple', None]
print([s.lower() for s in l if isinstance(s,str)==True])

print([x.lower() if isinstance(x,str) else x for x in l])

瑶池醉农

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

print([x.lower() if isinstance(x,str) else x for x in l])

这句语法显然错误


  • 1

Reply