Great, welcome again to this new video. This is the third video about errors. We
talked about syntax errors, we talked about exceptions, and now we're going to
talk about how to fix an error when you don't understand the message, so let's
focus on this error, a zero division error. In case you were good in mathematics you
could easily fix this error so you you'll be able to understand that you
cannot divide c by, you cannot divide a number by 0 so you'd fix this by
removing this expression here. However if you were not that good in mathematics you
may find this difficult to understand. In that case the fastest way to fix this
error is by copying this line here. Control C, so select it copy it with ctrl
C or right click and copy there and then go to Google. Just paste it. Now on Google
this got around a hundred thousand results so Python is very popular and
you'll get a solution for almost every problem that you'll get with Python
so before looking at documentation or asking a question somewhere it's very
likely that someone else has had your issue before and i have asked a question
about that and there is a solution about that as well.
And a very good question and answer website is stackoverflow.com and
almost always when you search for an error on Google the first results will
be from stackoverflow and so someone has asked a question with this title. It says
I faced an error when I run the program using Python. So it's the same things as
error as you like that. How to avoid that error? And if it also talks about the
desired output. And there are two answers for this
question. tThe answer with this green mark here is the accepted answering and it
has and it has the most up votes so 11 and this has 2 down votes some minus 2.
Actually the difference between up votes and down votes is in the favor of
down votes and so these are two different answers that you can look at. Usually you
want to look at the accepted answer that has the solution, however in this case
this also has the explanation it says you cannot divide by 0. This causes
Python to raise an error. That's single good answer and I think it didn't
deserve to get to have this balance of votes, but this one gives a
solution on how to handle an error and that takes us to another concept which
is handling errors in Python. So let's say you have a program you have a
function that gets two input values and then it divides those two input values.
However sometimes the user may pass zero as as a second input and in that
case if you divide, let's say the first value would be 2 and the second value
would be 0, your program would crash and if you want you can use exception
handling to actually avoid that program from crashing. And you can do that with a
try and accept statements. Anyway we'll cover that in the next lectures in this
section. So this was about searching for an error on Google and you can
easily find the solution to that as you see. These are very clear questions. It's
a big community and everyone can vote up and down and can comment and so
basically the answers are very accurate. However you'll not always find an answer on
Google. In that case it's time to ask your own
question, so the first thing is again you check if you understand the error and
fix it if you understand it. The second thing is you do a search on Google and
if the first to fail to solve your problem, then it's time to ask a question.
And you can ask a question either inside the course, so you can, while watching a
video you can browse Q&A which stands for question and answer and you can do a
quick search if you find an existing answer to your question here and if you
cannot find it then you can ask a question, or you can ask a question on
stackoverflow. You can use this button here, ask a question and I'll be happy to
help you here on the course interface Q&A section.
Or other people can also help you own stackoverflow, however something is very
important to know. The structure of your question is very important on getting a
good answer. You know sometimes there are very bad questions like let's
say my code is not working how do I fix this and that's all. With that very
little information is very hard to get a good answer so it's very important to
ask a good question and I'll show you how to ask a good programming question
in the next lecture. So that's a very important lecture as well. See you there!