Update 531.py

All exceptions are caught now :D