1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| # Creating a fake list
N = 10
list = [x for x in range(N)]
def to_be_deleted(element) : # Conditional function, takes an element of the list as argument
###
# Write here the function
###
return result #True if delete, False otherwise
# Starting while-loop
k = 0
ele = list[k]
while k<len(list) : # Loop until last element of the list has not been checked
if to_be_deleted(ele) :
list.remove(ele) # Removing the k-th element
ele = list[k] # Updating the element to be compared
else : k+=1 # Check the next one |
Partager