Python for Absolute Beginners Transcripts
Chapter: Error handling
Lecture: Practice time

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Of course it's time for you to practice
0:02 adding air handling, creating exceptions
0:05 and catching them in your program.
0:07 So that's what we're going to do in this practice exercise.
0:10 Here we are over in CH11, Error Handling
0:13 and we have a couple core concepts.
0:15 The basic try/except, which we talk about details here
0:19 and then also the more advanced
0:21 what do you do if you want to catch multiple errors
0:23 in one try block?
0:24 Like the JSON itself is malformed or the file isn't there
0:28 or the conversion didn't work or who knows what.
0:31 So it talks a little about that and then for your exercises
0:34 go back to tic tac toe that we created or if you made it
0:36 as far as Connect 4 in our practice exercise, you want
0:40 to use this one and the idea is to add error handling
0:43 around first the user input into the program using try
0:46 and except, and then think of other ways that your program
0:49 could crash like for example Control C from the terminal
0:52 that doesn't work in PyCharm but it does if you run it
0:55 from the terminal or maybe files are missing or other types
0:57 of things that could go wrong, so you can check
0:59 the trace back, that's the big dump of what went wrong
1:03 for the error type and you can add appropriate error
1:05 handling for those as well.
1:06 So just practice making your program much more polished
1:09 taking that input and handling those errors gracefully.
1:12 This is the sign of a professional, properly written
1:15 program not one that just takes only the happy path
1:18 and then anything at all deviates it crashes, you don't want
1:21 an app like that.
1:22 So take this time to make your apps more solid.