All right, now it is time to talk about Iraq handling's in by now, the first thing there is something
called the unbooked function in Python, which is like this in but up in the brackets inside it.
But the prompt message.
So please enter evalu.
On its do this and then we can print this value.
OK, but actually the store that inside aFunction, which is inside the variable, I mean, and it's
print the X like this so you can see this will receive an integer value or actually this is if you want
to see it, it is a string value actually, but we will print it out.
OK, so let's run this command.
I mean, the men did buy one, which is the Biton, so please enter a value I would put or I will enter.
Hello.
And you can see it now if this help has been printed.
But by the way, you can bet to be more elegant, actually.
You can put it in here with the space and let's try again.
So, yeah, you can see it now.
It is more elegant.
Please, you and I will put it on or whatever.
OK, so this is it.
OK, good.
So far, so good.
Now, let's return here and let's this time let's put another value, so twelve, yeah, it would give
us 12 again.
What if I couldn't hear some?
Yeah, everything is working correctly now this time.
What if I used the integer value like.
So I want this value to be entered as an integer.
OK, so I'm using the integer converter function, so anything we enter here must be integer or if not
integer, I will convert it.
OK, so let's run this and see into a value.
If I typed it, you can see that it is wrong.
Why?
Because invalid literally for and would based in a.
But again, if I run that and if I Rin Tin Tin is acceptable because this is an integer but if I run
or what any string value or any value rather than int.
It will show us this, OK, by the way, if I take ten point five, it will give us a road as well because
this is a float value.
The value must be integer only.
OK.
OK, so far, so good.
Now, how to do such a thing without error, without putting this on.
So we want the error to be handed.
OK, we don't need to print.
There are.
This is not elegant.
We need an elegant solution.
How to do that.
We would use that right.
Except which is the error handling in Python.
So how to do that by using tried to I what.
Try this.
OK, now, if there are errors or something, except so as you can see, these are inside the tri indentation.
So except.
And David Cooptation.
And on here, I mean, if they are, let's print, for example.
Oh, no, there is an error.
OK, and I think this is just a better example.
OK, so if I try this again when I enter 10 or any integer value, it works fine.
OK, so let's clear the screen and let's try enter high, for example.
Yeah, you can see that.
You can see now it is.
Oh no there is an error.
OK, so it handled the error with elegant way.
So if there are error here, not like before, before it will give us what is the error.
And actually this is bad.
No.
This time if we face any error, actually it will.
Brent, this statement, or it will do these things inside the accept, so, for example, your value
that has been entered as negative, you can inside that, except you can put it or use the absolute
function, the apps and convert it to something positive, and then you can assign it to the value you
want.
OK, well, actually it has a lot of use cases.
You can read about it if you are interested in it.
Actually, if you open your browser and you go or type.
Python is right, except.
Then you can go to the three schools dot com and here you can see that there are a lot of examples and
not just to try, except there are another format, which is that you can put arrays then in error and
another other errors actually you can see.
So try to accept them.
OK, and Brent.
And then finally accept this, OK?
So actually there are other formats like that using the Elsah as well.
So you can see try these printed or accept something else.
We have the finally and here you can see that it will be raised as you can see it, except Pindi.
So this will try to accept after it is finished.
And you can see there are a lot of examples here if you are interested to have or to learn more about
it.
OK, but anyway, it's not that big a deal to know everything, but just know that there are other format
and other use cases.
You can read more about it.
But for now, keep in mind this is the way to handle the errors in Python.
Thanks for watching.