This could easily mask errors. Please catch only KeyError here, or whatever it is you expect. You could also move the 'if' statements out of the try block to make it safer.