-1
我需要遍歷列表,但錯過列表中的特定元素,有沒有快速的方法來做到這一點?對於'列表'中的'元素'(但不包括元素X)
list = ['X','Y','Z']
for element in list (but not including element 'X'):
print(element)
>>>Y
>>>Z
我需要遍歷列表,但錯過列表中的特定元素,有沒有快速的方法來做到這一點?對於'列表'中的'元素'(但不包括元素X)
list = ['X','Y','Z']
for element in list (but not including element 'X'):
print(element)
>>>Y
>>>Z
seq = ['X','Y','Z']
for element in seq:
if element == 'X':
continue
print(element)