1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| >>> li = [3, 8, 5, 3, 6, 8, 3, 8, 5, 3, 6, 8]
>>> current_index = len(li) -1 # L'index commence a zero
>>> while current_index > -1:
... if li[current_index] > 7:
... print " + %d || OK" % (li[current_index])
... else:
... print " + %d || FAILED" % (li[current_index])
... _ = li.pop(current_index) # *****
... # li.pop(current_index)
... current_index -= 1
...
+ 8 || OK
+ 6 || FAILED
+ 3 || FAILED
+ 5 || FAILED
+ 8 || OK
+ 3 || FAILED
+ 8 || OK
+ 6 || FAILED
+ 3 || FAILED
+ 5 || FAILED
+ 8 || OK
+ 3 || FAILED
>>> li
[8, 8, 8, 8] |
Partager