How to delete elements while traversing the list in processing.py?