+ 2

How to handle a try/except so it doesn't stop iterating

The program detects dates in the format dd/mm/yyyy. I would like my list of invalid_dates to include all of them, not just the first it finds. How should I organize my try/except so it can continue iterating after finding an exception? (full description in the code) https://code.sololearn.com/cIvgf8piFf3o/?ref=app

4th Mar 2020, 12:25 AM
Alina Sansevich
Alina Sansevich - avatar
3 odpowiedzi
+ 4
Maybe you can add a “for” loop before the try/except block. For example: for i in ......(an iterator) try: ............(do sth with i) except: ............(do sth else)
4th Mar 2020, 12:50 AM
QWKKK
QWKKK - avatar
+ 4
QWKKK Alexandr That was so simple, thank you!!!!! I guess I should have taken a break before asking this question 😅
4th Mar 2020, 1:06 AM
Alina Sansevich
Alina Sansevich - avatar
+ 1
😜😜😜
4th Mar 2020, 1:07 AM
QWKKK
QWKKK - avatar