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
|
432 Discussions
|
Please Login in order to post a comment
if name == "main": count = int(input()) for i in range(count): a,b = input().split() try: print(int(a)//int(b)) except (ZeroDivisionError,ValueError) as e: print("Error Code:",e)
Here is HackerRank Exceptions in python solution - https://programmingoneonone.com/hackerrank-exceptions-problem-solution-in-python.html
T = int(input()) inputs = [] for _ in range(T): inputs.append(input())
for i in inputs: try: A, B = map(int, i.split()) print(A//B) except ZeroDivisionError as e: print(f"Error Code: {e} ") except ValueError as e: print(f"Error Code: {e} ") **