Python Forum
Help with Exception to error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Exception to error
#6
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
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.
Reply


Messages In This Thread
Help with Exception to error - by harveyl12 - Mar-12-2018, 10:49 PM
RE: Help with Exception to error - by harveyl12 - Mar-13-2018, 06:48 PM
RE: Help with Exception to error - by sparkz_alot - Mar-13-2018, 06:56 PM
RE: Help with Exception to error - by harveyl12 - Mar-13-2018, 07:19 PM
RE: Help with Exception to error - by micseydel - Mar-14-2018, 12:10 AM
[split] Help with Exception to error - by harveyl12 - Mar-13-2018, 08:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to write exception error into logger mg24 3 1,042 Nov-15-2022, 04:20 PM
Last Post: insharazzak
  pywin32 Illustrator Throwing Exception Error matthewsjc1 7 5,785 Aug-27-2021, 02:43 AM
Last Post: Larz60+
  SystemError: error return without exception set!!! faryad13 3 3,815 Oct-23-2020, 02:32 PM
Last Post: ATARI_LIVE
  Exception: Returned Type Mismatch Error devansing 1 5,249 Mar-06-2020, 07:26 PM
Last Post: ndc85430
  i am getting error while writing code for exception logging rkgupta51179 1 1,899 Nov-03-2019, 05:12 AM
Last Post: buran
  During handling of the above exception, another exception occurred Skaperen 7 27,041 Dec-21-2018, 10:58 AM
Last Post: Gribouillis
  Can't find error in code but Python throws exception Sandwich_masterX 3 3,021 Oct-09-2018, 01:38 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020