我需要浏览一个列表,但错过了所列表中的特定元素,有没有快速的方法可以做到这一点?
list = ['X','Y','Z']
for element in list (but not including element 'X'):
print(element)
>>>Y
>>>Z
答案 0 :(得分:2)
seq = ['X','Y','Z']
for element in seq:
if element == 'X':
continue
print(element)