Discuss / Python / 借鉴了别人的作业

借鉴了别人的作业

Topic source

13个望辰

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-
L1 = ['Hello', 'World', 18, 'Apple', None]
L2=[s.lower() if isinstance(s,str) else s for s in L1]
print(L2)

['hello', 'world', 18, 'apple', None]

推测,if和for循环判断的次序并不是固定的


  • 1

Reply