Python for Absolute Beginners Transcripts
Chapter: Error handling
Lecture: Where are the invalid numerals
0:00 Well, let's fix this crashing program that we've got going on here. Notice we're over in error handling, rps error handling.
0:08 This is in CH11 in the GitHub repository. And I've already sort of set this up a little bit for us.
0:14 We've got the rpsgame, and it should look really familiar. Except for there's a few issues we're going to solve that in a second
0:20 but this starts up and it's going to say Oh, not external libraries but error handling addition. So what we've done is we've taken
0:27 the external libraries edition, CH10 and we've copied it over with some small changes. Remember the way it worked before is
0:35 we gave it that cool dropdown thing where it could figure out what, you know what you're starting to type like a Oh do you want to type error
0:42 and it would just complete that for us. We've fallen back in a bit in our get roll here. Where we're going to get the input from the user
0:51 and we're converting it to an integer again. Specifically 'cause that's a super easy way for us to crash the program.
0:56 Now, notice there's some requirements that are here we got to install from our requirements file. There's a couple of options.
1:02 We can click this button, and that's great or we can come down here. Make sure your virtual environment is active and you can say, pip install -r
1:11 requirements.txt and it'll complete that for us. Cool, now we should be able to run this program. We don't care about this extension for
1:19 the requirements.txt. A lot of the extensions in PyCharm are awesome. They've got great ones for like, CSVs and Nginx files, and all kinds of stuff.
1:26 But for some reason the requirement one messes with that little dialogue that you just saw there, that yellow bar so I don't use it.
1:33 Anyway, we're ready to run our game here. Let's see that it works. Let's see that everything is working good.
1:38 Yes, my name is Michael, or is it Crash Bandit? Okay, seven, yeah, not so much. That's not great. But one thing that's cool about PyCharm
1:46 is when you do have an error notice over here on the right you can see the various places where this is happening and we can just click right here
1:54 and yeah bump that down a little bit and it takes us right to the line where the error first happened. Well, here's where the error is.
2:02 So you can see what's going on. We're passing in seven as like this and it really wants us to pass in that
2:10 the numeral 7, but it's not going to happen, is it? So it's this error right here, and in fact we can sort of guard against this whole bit right there
2:19 to make sure that everything is working correctly. We'll see how to do that next.