Discuss / Python / 努力啊

努力啊

Topic source

L3有点多余在前面写 if else ,去掉if else就是L4。

L3,L4针对  18 这个数字,实用性不大,只不过为了试一下if else 在前面怎么写

L2 = [s.lower() for s in L1 if(isinstance(s,str)==True)]

L3 = [s.lower() if isinstance(s, str) else s for s in L1 if s if s!=18]

L4 = [s.lower()  for s in L1 if s if s!=18]

  • 1

Reply