Contenido del Curso
Error Handling in Python
Error Handling in Python
Challenge: Catch an Error
Now, let's handle the error for the first time.
You should handle this error:
from math import sqrt sqrt(-4) # ValueError
Since finding the square root of a negative number is not possible (according to mathematical concepts), performing this operation in Python is not feasible. The interpreter takes this into account and raises a ValueError
with the following message: math domain error
.
Tarea
Now, you need to complete the following points:
- Define the code block where an error is expected.
- Catch this error and print the following string:
"The ValueError was raised!"
¡Gracias por tus comentarios!
Challenge: Catch an Error
Now, let's handle the error for the first time.
You should handle this error:
from math import sqrt sqrt(-4) # ValueError
Since finding the square root of a negative number is not possible (according to mathematical concepts), performing this operation in Python is not feasible. The interpreter takes this into account and raises a ValueError
with the following message: math domain error
.
Tarea
Now, you need to complete the following points:
- Define the code block where an error is expected.
- Catch this error and print the following string:
"The ValueError was raised!"
¡Gracias por tus comentarios!
Challenge: Catch an Error
Now, let's handle the error for the first time.
You should handle this error:
from math import sqrt sqrt(-4) # ValueError
Since finding the square root of a negative number is not possible (according to mathematical concepts), performing this operation in Python is not feasible. The interpreter takes this into account and raises a ValueError
with the following message: math domain error
.
Tarea
Now, you need to complete the following points:
- Define the code block where an error is expected.
- Catch this error and print the following string:
"The ValueError was raised!"
¡Gracias por tus comentarios!
Now, let's handle the error for the first time.
You should handle this error:
from math import sqrt sqrt(-4) # ValueError
Since finding the square root of a negative number is not possible (according to mathematical concepts), performing this operation in Python is not feasible. The interpreter takes this into account and raises a ValueError
with the following message: math domain error
.
Tarea
Now, you need to complete the following points:
- Define the code block where an error is expected.
- Catch this error and print the following string:
"The ValueError was raised!"