Try, except how to use?

https://www.codecademy.com/paths/data-science/tracks/dspath-functions-and-logic/modules/dspath-control-flow/lessons/python-control-flow/exercises/try-and-except-statements

i don’t understand this concept, in editor you use ‘raise’ but didn’t explain, and the example is not enough for me to get it.
what is this used for in real life, what kind of input will get what result. have nothing.

Hey @haodo9x2317615806!

I’m not exactly sure what your question is… are you asking what the application of this would be in real life?

I would say that the point of this is to catch specific bugs and by having an error statement like that, you know exactly what the problem is.

Also, all that raise ValueError does is raise a valueerror. I don’t think it needs to be explained because:

  • It’s kinda self explanatory
  • its not the point of the exercise.
    The point of the exercise was to learn how to leave specific error messages when you attempt to call different functions.

Hope this helps!
Steven

here, this picture, until i go to this quiz , i understand what it is used for, you really need to rewrite this part like this. this is real example.

try

1 Like

You’re right, this lesson isn’t explained very well. I would recommend submitting a bug report, and labeling it “Improvement” so then the people who actually have the power to change this can fix this issue.

i thought you had more than that power lmao.

1 Like

Nope! No one on the forums will be able to change the actual exercises, which is why I recommend sending a bug report