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.
- Prepare
- Python
- Errors and Exceptions
- Exceptions
- Discussions
Exceptions
Exceptions
Sort by
recency
|
380 Discussions
|
Please Login in order to post a comment
n=int(input()) for i in range(n): try: a= input().split() b=a[0] c=a[1] print (int(b)//int(c)) except ValueError as v: print(f"Error Code: {v}") except ZeroDivisionError as e: print("Error Code:",e)
I have to change my code like this (writing error message by hand instead of using the default error name):
I am getting zero division error from compiler as follows "ZeroDivisionError: division by zero". But in the test cases the correct error message must be like this: "Error Code: integer division or modulo by zero , Error Code: invalid literal for int() with base 10: '$'". I am happy if anyone know how to fix this or is it a problem with the hackerrank compiler.