Sort by

recency

|

431 Discussions

|

  • + 0 comments

    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)

  • + 0 comments

    Here is HackerRank Exceptions in python solution - https://programmingoneonone.com/hackerrank-exceptions-problem-solution-in-python.html

  • + 0 comments
    1. This question ask us to accept a,b
    2. but first give me how may of them i should have
    3. 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} ") **

  • + 0 comments
    n = int(input())
    
    for _ in range(n):
        try:
            a, b = input().split()
            print(int(a) // int(b))
        except ZeroDivisionError as e:
            print("Error Code:",e)
        except ValueError as e:
            print("Error Code:", e)
    
  • + 0 comments

    T = int(input()) for i in range(T): try: a,b = input().split() a = int(a) b = int(b) c= int(a/b) print(c) except ZeroDivisionError as e: print("Error Code: integer division or modulo by zero") except ValueError as v: print("Error Code:",v)