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.
after that preform division and handle errors as ZeroDivisionError and ValueError
In my code the first loop stores our input and the second do the work i meantioned before
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} ")
**
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Exceptions
You are viewing a single comment's thread. Return to all comments →
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} ") **