# coding: utf-8 li = [1,2,3,4,5] for num in li: while True: try: # do something except some error: continue break