Python Tutorial: Error Handling | Try-Except-Finally

preview_player
Показать описание
In this video, we will be taking a look at how to handle errors and exceptions. Often, when you develop programs for end users, you don't really want to directly show them the error messages in case you face an error. So, it is much better to handle errors when they are thrown by your program in a way that goes easy on the users using your application.

Although the Error Handling topic is vast, this video covers the fundamentals to keep you aware of the different blocks that we use to handle exceptions, namely try, except and finally blocks.

Enjoy the video.

____________________

Hmm, I wonder where these links takes us :

____________________

ZBunker is a community that is run by a bunch of university students with strong grasp on computer science fundamentals.
The channel will walk you through some of the popular programming languages and how you can develop a skill set in this tech domain.

We strive to provide free and quality education for all. We firmly believe that open source is the way forward. So, by making these videos, we are encouraging and empowering you to do open source contributions and give back to the community.

We are learners. We are coders. Let's make an impact.

____________ WE NEED YOUR SUPPORT ______________

We strive to make education free 4 all. We would love to share this to as many audiences as possible. This won't be possible without your support. So, if you liked our videos, kindly consider subscribing to our channel.

Support us on:

Drop us a Feedback:
Рекомендации по теме
Комментарии
Автор

There is a neat way of Identifying the type of the error that needs to be passed along with the except block. What you have to do is let the error actually happen and read the last line of the error log. Most probably, the type of the error would be mentioned there. For example

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate str (not "int") to str

In the last line, you can see the type of the error is TypeError. So, in order to catch this error, you have to pass TypeError with except block. For example

try:
<your code here>
except TypeError:
print("TypeError occured!")

pranavu
visit shbcf.ru