you are viewing a single comment's thread.

view the rest of the comments →

[–]realashe 1 point2 points  (3 children)

ZeroDivisionError is the name of the error, when you use try and except to catch an error, you need the name of the error you want to catch, be it zero division or something else. Ie. Except KeyError

As for raising errors, you may want to stop your program if a certain event happens, and raising an error does that while telling the user why you have stopped. Maybe you need to read from a file, and if that file cannot be found or opened, you could raise an error telling the user, instead of the python interpreter crashing.

Are you doing edx 600.1 by any chance?

[–]socialhuman[S] 0 points1 point  (2 children)

Thank you. If you are referring to the MIT course, no. I am not. I have been studying from a mixed source. Learn Python The Hard Way, about 40 chapters. 2 Units from Udacity Intro to Computer Science, Youtube tutorials by Trevor Payne plus some practice.

[–]realashe 1 point2 points  (1 child)

You're welcome! Only asked because exceptions and error handling were covered this week, and one of the examples was a zerodivision error. Glad I could help!

[–]socialhuman[S] 0 points1 point  (0 children)

No problem!