You can use an indexed for-loop (using the index to retrieve the element).
mylist = ["dog", "cat", "lion", "wolf", "zebra", "monkey", "bear", "eagle", "bison"]
for i in range(len(mylist)):
if i in [4, 5, 6]: # element indices to skip
continue
print(mylist[i]) # procedures desired
The alternative way to do so, is to modify the for-loop range, which would save two lines of code doing if
. (This is a relatively bad idea)
mylist = ["dog", "cat", "lion", "wolf", "zebra", "monkey", "bear", "eagle", "bison"]
for i in (mylist[:4]+mylist[7:]): # exclude the skipped ones
print(mylist[i]) # procedures desired
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…