Mar-14-2018, 12:10 AM
You only need to change the last block of code you provided. Wrap the four lines within the function in a try, and then catch the KeyError.
I suspect that's not really what you want though. For one thing, you can replace code like
I suspect that's not really what you want though. For one thing, you can replace code like
poke['iv_atk']with
poke.get('iv_atk', None)That aside, I find it weird that a Pokemon would not have those IVs. You probably should prevent that input being provided to that function, rather than making the function tolerant of bad input.