Python Tutorial: Using Try/Except Blocks for Error Handling

  Рет қаралды 712,938

Corey Schafer

Corey Schafer

Күн бұрын

Пікірлер: 484
@AdamThao92
@AdamThao92 4 жыл бұрын
Better content here than most paid-training content.
@iman2020
@iman2020 4 жыл бұрын
Exactly
@isharadhanushka7643
@isharadhanushka7643 4 жыл бұрын
damn right
@sujithnair232
@sujithnair232 4 жыл бұрын
Totally Agree
@pengli1175
@pengli1175 4 жыл бұрын
Yep
@satyamvats5438
@satyamvats5438 3 жыл бұрын
Exactly. These people helps us to go further even if we are not affordable of paid courses 😊
@paul8683
@paul8683 7 жыл бұрын
You sir are a gift to amateur programmers.
@WasiMaster
@WasiMaster 4 жыл бұрын
@Abishek Raju Utoobguy
@ciaocomestai2372
@ciaocomestai2372 3 жыл бұрын
@@xfire3778 how your programming status?
@ciaocomestai2372
@ciaocomestai2372 3 жыл бұрын
@@xfire3778 Wow, you learned a lot, gg
@REVIEWSGALATTA
@REVIEWSGALATTA Жыл бұрын
Aiyoo namma mind Anga pogudhe 😂😂
@AGMS1234
@AGMS1234 Жыл бұрын
​@@REVIEWSGALATTAVanakkam nanbare
@waynenewark5363
@waynenewark5363 2 ай бұрын
I'm a retired mainframe developer just starting out using python. Thanks for this helpful video.
@johnvictorengland7703
@johnvictorengland7703 6 жыл бұрын
Finally somebody who explains it well, in proper English and concisely.
@panicbydesign7315
@panicbydesign7315 7 жыл бұрын
I have been looking everywhere and just could not wrap my head around multiple exceptions. Your explanation is succinct and well demonstrated. THANK YOU! I will be going back and watching the rest of your tutorials.
@FeedFall8
@FeedFall8 5 жыл бұрын
i know right dude!
@ShivamSingh-bx5lg
@ShivamSingh-bx5lg 5 жыл бұрын
Did you get the job?
@mohammedalzamil7191
@mohammedalzamil7191 4 жыл бұрын
hey did u get better / continur with coding?
@twattusbobble9845
@twattusbobble9845 2 жыл бұрын
I have just been battling all day with coding challenges in MIT intro to computer science for the error handling section. I've watched this video once and I now get it perfectly. You're really really good at explaining stuff!
@kimcato5326
@kimcato5326 5 жыл бұрын
I love your videos! They are very well explained and short... better than my professor's. I am writing better programs because of your videos. Your videos are a GOD send.
@opiyosebastian
@opiyosebastian 5 жыл бұрын
Thank you Corey....I continue to follow and grow as a self made developer. You my best teacher!!
@iamgalaxey
@iamgalaxey 6 жыл бұрын
My class doesn't explain this as well as you do i was able to easily understand this after watching this video. thank you!
@Xaminn
@Xaminn 4 жыл бұрын
*Puts entire project inside a Try and Except block*
@narenmohan3426
@narenmohan3426 4 жыл бұрын
LOL XD
@kwan098
@kwan098 4 жыл бұрын
we're not suppose to do that? uh ohh
@mohammedalzamil7191
@mohammedalzamil7191 4 жыл бұрын
so where did u get in programming?
@Xaminn
@Xaminn 4 жыл бұрын
Mohammed Alzamil I have built a couple of small applications. Real estate web scraper and some audio analyzer software thing. However, it’s complete spaghetti code. Any other programmer would probably laugh lol
@mohammedalzamil7191
@mohammedalzamil7191 4 жыл бұрын
@@Xaminn lol ive been coding for about a month and built a coronavirus tracker and an ig bot that likes stuff and im currently upgrading it also built some shit witth tkinter using apis and shit
@dp0813
@dp0813 5 жыл бұрын
word = 'currupt' try: if word != 'corrupt': raise ValueError except ValueError: print("Corrupt is spelled wrong!") >>> Corrupt is spelled wrong! :-D
@asiddiqi123
@asiddiqi123 5 жыл бұрын
LOL!
@rohanghoshdastidar1047
@rohanghoshdastidar1047 4 жыл бұрын
N I C E
@TaiwanBnB
@TaiwanBnB 4 жыл бұрын
hahahaha
@ineedsolution
@ineedsolution 5 жыл бұрын
This the best explanation of try / except concept ever.
@mohammedalzamil7191
@mohammedalzamil7191 4 жыл бұрын
did you get better with coding it's been a year
@sammavrs
@sammavrs 2 жыл бұрын
always a great feeling when my "professor" links your videos. STUDENT LOANS HERE I COME!!
@genem5659
@genem5659 2 жыл бұрын
7 years later, this tutorial is still helping people! xoxo
@michaelhagans965
@michaelhagans965 4 жыл бұрын
Awesome. Thanks for clearing that up for me. You can also raise your own custom exception such as: 'raise Exception('This is a custom error you can create.')
@cibelless510
@cibelless510 4 жыл бұрын
Always a surprise video. Other guys are good too, but they are a little confuse some times. But you always very clear such as ...Begin --- middle ---End....Good for you man.
@nitkap441
@nitkap441 4 жыл бұрын
You are awesome. As I had remarked in another of your video, you are the most efficient learning resource... Each minute is worth it. In other places, I feel like a 30 minute video should ve edited to 15-18min so that I can get the real stuff... Here I get every minutes worth... The learning is very very efficient for me!
@younghwanchae1422
@younghwanchae1422 4 жыл бұрын
The way you teach how to program is so great, not to mention the contents.
@morteza1736
@morteza1736 Жыл бұрын
5:24 THIS IS MUCH MORE EASIER THAN READING TRACEBACK ERROR!!!!!! Thank you So much
@alalhaj220
@alalhaj220 2 жыл бұрын
this is exactly what i was looking for, instead of defining all of the exceptions i wanted to print a message when an unwanted value was the input
@peschebichsu
@peschebichsu 3 жыл бұрын
Your video are many years old and still on most of the topics one of the best resscource, thanks a lot!
@soumyazyx
@soumyazyx 5 жыл бұрын
Thank you Corey for your time and effort. Keep spreading the knowledge.
@blossoms2u
@blossoms2u Ай бұрын
Thank you !! feeling bad i found this treasure 8 years later , still happy that i have found it now !
@navidmohammadzadeh2141
@navidmohammadzadeh2141 6 жыл бұрын
The best tutor ever! The best in the world! Thank you so much!
@A.O.U
@A.O.U 3 жыл бұрын
This is how you learn something in 10 minuteS. THANK YOU SIR , your explanation is AMAZING.
@hollyjo161821
@hollyjo161821 3 жыл бұрын
Had to donate - I've watched your Channel ALL Day. I have learned more than I deserve. Thank you!
@edgarlip2
@edgarlip2 5 жыл бұрын
awesome as usual !!! just wanted to add some little detail about the raise , u can do it like if(name == ''): raise Exception('name is empty , please specify a name !')
@Sneaadler
@Sneaadler 2 жыл бұрын
I love that you, visulize this with a real error insted of faking one
@abdelhadialhnsh7228
@abdelhadialhnsh7228 7 жыл бұрын
I have looked around to understand this topic and finally, I found the best explanation ........good job ...please keep going and share more tutorials
@coreyms
@coreyms 7 жыл бұрын
Glad it helped make sense of the topic :)
@danielgerman4757
@danielgerman4757 4 жыл бұрын
This type of good explaining that you do, should be taught to teachers! Thank you for all your hard work and dedication.
@bikeshtiwari
@bikeshtiwari 5 жыл бұрын
You made me learn many concepts in python. Ur awesone teacher
@dakota5569
@dakota5569 4 жыл бұрын
I could watch this perfectly at 1.75 for a quick recap/rundown. Take my like
@DonDynAyt
@DonDynAyt 7 жыл бұрын
Hi Corey, I just wanted to tell you how much I appreciate your videos. You're doing a great job, clear and concise. Thanks!
@kdSU30
@kdSU30 Жыл бұрын
1:21 2:40 4:34 the most crucial messages of this video!
@marcello4258
@marcello4258 3 жыл бұрын
best tut in regards to this topic on YT this seems also to be the case for other languages not only for python
@alexandrucretu1016
@alexandrucretu1016 5 жыл бұрын
Your videos are very helpful, Corey! tyvm Also, just to point out that it is better to close the file (f.close()) within the finally block, because it will be executed anyway, while the else block runs only if the try clause doesn't raise an exception.
@uzomaobasi3767
@uzomaobasi3767 5 жыл бұрын
do you know why an exception is thrown when he mislabels the file name? and not the FileNotFoundError? It says ErrNo2 but shouldnt it be ErrNo1?
@JUDOGAR
@JUDOGAR 3 жыл бұрын
Excellent! Loud and clear!!!! More than most of the paid courses...Thanks a lot Teacher Corey!
@junaidjawedkhan5888
@junaidjawedkhan5888 6 жыл бұрын
This is the best explanation I've read! - Thank you!
@crazyvashisth
@crazyvashisth 5 жыл бұрын
Now that's how to explain. Well done Corey😄😄😄😄🍻
@VelezBiH
@VelezBiH 7 жыл бұрын
Thank you for explain the error handling in python. You are my favorite KZbin teacher on python!
@danielEpifanov
@danielEpifanov 4 жыл бұрын
probably most informative video on youtube
@paulmk2290
@paulmk2290 4 жыл бұрын
Seriously, you should consider putting together a course on Udemy, or the like. I am here now because the instructor on the course I am currently doing assumed that I knew everything you just explained. Also, I note that you covered what you are doing properly and thoroughly. Not everybody is capable of doing that.
@PHXKHEEDGAMING
@PHXKHEEDGAMING Жыл бұрын
😹😹😹😹😹😹😹😹😹they always assume what they are supposed to be teaching
@martinh9099
@martinh9099 27 күн бұрын
Thanks..saved me hours of work!
@josekodek4938
@josekodek4938 6 жыл бұрын
You have helped me really a lot in learning programming Allah Bless you Mr.Corey Schafer
@sixie6e
@sixie6e 4 жыл бұрын
other python videos, the person just narrates what they are doing without successfully explaining the concepts behind it. this is why you need to watch corey's videos. he doesn't make videos to show others he can code, he makes them so others can LEARN!
@brolord1288
@brolord1288 2 жыл бұрын
That moment when you like a video you already liked :) Great tutorial, thanks!
@jhpk4495
@jhpk4495 7 жыл бұрын
Thank you so much thats what i need for my program! and also you helped me in mastering python! keep up the great work!.
@user-pe9qg3hg3k
@user-pe9qg3hg3k 2 жыл бұрын
I saw a video before where someone said that to use try: / except: was bad because they said if something fails it should just break, but they totally missed the point of it. Try except is super useful when paired in while loops with booleans to determine whether user input is able to be converted with no issue, for example
@Parvej669
@Parvej669 5 жыл бұрын
Thanks for the video. I learned Exception handling from here.
@gledhillholdingsptyltd2654
@gledhillholdingsptyltd2654 6 жыл бұрын
Best Python tute on the web
@soroushsoltani919
@soroushsoltani919 2 жыл бұрын
Your nice sir ! i was absent in the classroom but i had the opportunity to learn it here
@Kelvo980908
@Kelvo980908 6 жыл бұрын
Thank you! Much better than how my professor explained it.
@kenrosenberg8835
@kenrosenberg8835 4 жыл бұрын
Short and simple, great video
@urbandude823
@urbandude823 7 жыл бұрын
I've been trying to learn how to do a working try/except for like a year, and nothing made sense until now. Thank you!
@austinmorara7954
@austinmorara7954 Жыл бұрын
commenting seven years later😂Thank you for creating this video, Its really helped me understand Exceptions better.
@rezamostafid8810
@rezamostafid8810 2 жыл бұрын
Corey: very clear and useful introduction of all the main features and caveats....better than the Python book I'm current using to learn python. I'm not sure if you did this intentionally but you mention some points at the beginning ( and also later on ... ) that provide the motivation for exceptions to begin with. This in turn allows much better understanding of the 'else' and 'finally' clauses as well as the 'raise' Thanks for clearing the fog in my head!
@MK1985-z7k
@MK1985-z7k 5 жыл бұрын
Excellent explanation as to when to use this.Also by showing an example the concept just sits in head :-) Good job Corey
@alainkr
@alainkr 4 жыл бұрын
Why would you unlike this video. Don't understand. Thanks Corey
@julijanaskova438
@julijanaskova438 5 жыл бұрын
Very clearly organized and explained, thanks!
@Assanken
@Assanken 9 жыл бұрын
The most vivid and comprehensive explanations ever! Great videos.
@oluwatobilobaadeyemi2008
@oluwatobilobaadeyemi2008 2 жыл бұрын
This is a great. Simple clear concise.Thank you
@ab5848
@ab5848 3 жыл бұрын
Thanks a ton Corey🙏 I hereby pronounce you as my ultimate Guru🙏
@SuperMechtronics
@SuperMechtronics 4 жыл бұрын
This exception video is exceptionally excellent
@silverflash1675
@silverflash1675 7 жыл бұрын
explained very well! thank you
@ViralKiller
@ViralKiller 4 жыл бұрын
raise Exceptions lol, I just want to get rid of them all
@andrey1652
@andrey1652 4 жыл бұрын
Lol imagine having errors pfffff
@aerahtv0000
@aerahtv0000 3 жыл бұрын
i honestly hate try/catch and all that jazz, in c++ i could atleast choose, to use them or not, i made my own testing functions and it was better, as it was straight forward, specific to my project, doesn't clutter the code and little bit better in terms of performance. Now i'm learning python and looks like the only way to deal with errors in this language is this shit
@shiro3940
@shiro3940 3 жыл бұрын
I just want to confirm that I undestand it correctly. so the "try" code, is trying to execute the code we want. if there's an error, the "except" code is for catching that. if the "try" code did not throw any error, the "else" code gets executed, and this is where the next step of the code executed inside "try" should be doing next. "finally" will execute regardless if there's any error or not.
@terguunzoregtiin8791
@terguunzoregtiin8791 5 жыл бұрын
Hope I saw this earlier. And I have a question, when should we use exception handling? When opening file or handling user input, I know we should use it. But on other circumenstances, I'm not sure. So could you please explain when it should be used? Thanks in advance.
@officesuperhero9611
@officesuperhero9611 6 жыл бұрын
Another awesome video, Corey! Amazingly clear and concise. Thank you.
@mathieuseligmann9488
@mathieuseligmann9488 4 жыл бұрын
Thank you so much !!!! You have just helpt me a lot !!! 10 minutes and learning so much that is so great. Again thank you very much.
@niteshtiwari1828
@niteshtiwari1828 6 жыл бұрын
Best explanation about exceptional handling
@chaitanyayeturi1312
@chaitanyayeturi1312 3 жыл бұрын
First of all, your teaching style is good, and anyone grabs ur teachings easily, and thanks for teaching us. you are the best tutor I have ever come up with in python language. can u suggest any python language book, which is best to go through other than your channel? Moreover, I am a beginner to python language I thoroughly enjoyed ur videos, if u can suggest me best python book to ur sensibility and I guess it suits me and it helps me to learn further (I like physical like books). In case if u written any books related to this language can u suggest one (or) your favorite book, please......................................
@satyamvats5438
@satyamvats5438 3 жыл бұрын
Very Nice ! You understand us each & every deep concepts of the functions.
@akinkanju9653
@akinkanju9653 9 жыл бұрын
Corey, thanks for these useful videos. I've watched all your videos about Python. Please consider covering scraping and regular expressions. Cheers!
@coreyms
@coreyms 9 жыл бұрын
+Seun Ade Thanks for the suggestions! I'll try to put some videos together on those topics.
@r01blue
@r01blue 3 жыл бұрын
Best ever video!!! Trank you!! Regards from Argentina.!!!!
@aayushgarg12
@aayushgarg12 4 жыл бұрын
Thank you so much Corey sir. Your video helped a lot. Your video made my concepts clear about try/except.
@koteswararaogudla2675
@koteswararaogudla2675 7 жыл бұрын
Loved the way when you started with pass statements dude.. thank you
@SquidScopes
@SquidScopes 3 жыл бұрын
from five years later, this is still useful.
@MrVwin
@MrVwin 8 жыл бұрын
Perfect Tutorial. Thank you Corey
@boombot9615
@boombot9615 4 жыл бұрын
good explanation, cleared almost all of my doubts
@tobyladeoghenetega4793
@tobyladeoghenetega4793 Ай бұрын
Incredibly useful video So that was why my code kept running the except block even with the right input😅
@manjitsingh1124
@manjitsingh1124 5 жыл бұрын
Thanks for the lesson Corey !
@SK-gn3rs
@SK-gn3rs 3 жыл бұрын
I like the video even before watching...when I see it is your video....
@nikolahuang1919
@nikolahuang1919 7 жыл бұрын
too good. So clear and no strange accent.
@ymany3277
@ymany3277 4 жыл бұрын
amazing video and very simple and clear explanation.
@ramasubbareddy6147
@ramasubbareddy6147 7 жыл бұрын
superb explanation on exception handling in python
@michelkant
@michelkant 6 жыл бұрын
This is so interesting and makes it nicer to experiment with code. The question then becomes: Don't you use this everywhere in your code?
@202ashish202
@202ashish202 2 ай бұрын
Boss...you are exception for 'all paid videos explanations' 😉
@adamsmith5374
@adamsmith5374 7 жыл бұрын
This video helped me a great deal to wrap my head around this topic. Thank you very much!
@secure_the_bags620
@secure_the_bags620 4 жыл бұрын
Man thank you for making this video. I finally understand!!
@rycitomorell5945
@rycitomorell5945 3 жыл бұрын
You are a real life hero!
@MauriceWilliams
@MauriceWilliams 3 жыл бұрын
YEEEESSSS! Soon I will have great awesome superpowers (from knowing how to code).
@snssatyabhagavan
@snssatyabhagavan 4 жыл бұрын
thank you very much for this video i am struggling with it from so many days
@szenghoe
@szenghoe 6 жыл бұрын
Thank you very much! your tutorial series is really helpful!
@FeedFall8
@FeedFall8 5 жыл бұрын
This video Helped ALOT! in my game development
@migueldomingos4570
@migueldomingos4570 4 жыл бұрын
What are you using to make game dev in python ?
@tinylittleanj2
@tinylittleanj2 4 жыл бұрын
Miguel Domingos probably pygame
@MohaDou
@MohaDou 4 жыл бұрын
with python ? o_0
@FeedFall8
@FeedFall8 4 жыл бұрын
Its pygame :D, btw pygames pretty good for 2D games, you just need to write efficient code to get 200+ fps on complex games
@RomanReigns-ds8hs
@RomanReigns-ds8hs 4 жыл бұрын
Awesome content !! Thanks for these videos.
@SJ-vc2tz
@SJ-vc2tz 4 жыл бұрын
Very clear explanation, thank you!
@akanimoakwa1892
@akanimoakwa1892 7 жыл бұрын
Thanks bro. You explained the topic so well. I am really grateful.
@joshualipovetsky2744
@joshualipovetsky2744 7 жыл бұрын
Excellent video, Corey! Thanks so much!
@RealToriMan
@RealToriMan 6 жыл бұрын
Best teacher ever
@manuzsanand
@manuzsanand 6 жыл бұрын
Very well explained. Thank you.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 310 М.
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 16 МЛН
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,7 МЛН
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 137 МЛН
Python Tutorial: Unit Testing Your Code with the unittest Module
39:13
Corey Schafer
Рет қаралды 1,3 МЛН
Advanced Exception Handling in Python
12:06
NeuralNine
Рет қаралды 67 М.
Python Tutorial: File Objects - Reading and Writing to Files
24:33
Corey Schafer
Рет қаралды 1,8 МЛН
Python exception handling ⚠️
7:39
Bro Code
Рет қаралды 65 М.
#63 Python Tutorial for Beginners | Exception Handling
15:59
Telusko
Рет қаралды 530 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 628 М.
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 415 М.
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 16 МЛН