We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
** is used as the exponentiation operator. Ex: 2**3 = 8.
ValueError is raised when a function receives a value which is the right type (in our case "int") but has an inappropriate value (n < 0, p < 0). "Exception" on the other hand is more generic. That being said, I would use ValueError because that's the kind of exception we're looking for.
Day 17: More Exceptions
You are viewing a single comment's thread. Return to all comments →
** is used as the exponentiation operator. Ex: 2**3 = 8. ValueError is raised when a function receives a value which is the right type (in our case "int") but has an inappropriate value (n < 0, p < 0). "Exception" on the other hand is more generic. That being said, I would use ValueError because that's the kind of exception we're looking for.
For further info, http://stackoverflow.com/questions/2052390/manually-raising-throwing-an-exception-in-python