Python IndexError: what's wrong?

Because none of your patterns ever match, the loop will keep incrementing the idx until it goes over the bounds of the tuple.

The reason for no match, is that you have a small error in your last regex pattern. This:

r'([\w\D]+) (\d{2}) , (\d{4})')

should be:

r'([\w\D]+) (\d{2}), (\d{4})')

After fixing this I’m able get the correct output from the program:


Browse More Popular Posts

Leave a Comment