Sort by

recency

|

413 Discussions

|

  • + 1 comment

    my code :

    t = int(input())

    for _ in range(t): elements = input().split()

    try:
        r = int(elements[0]) / int(elements[1])
        print(int(r))
    except ZeroDivisionError as ze:
        print("Error Code: integer division or modulo by zero")
    except ValueError as ve:
        print(f"Error Code: {ve}")
    
  • + 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

    Here's my code:

    for i in range(int(input())):
        try:
            a, b = map(int, input().split())
            print(a//b)
        except Exception as e:
            print("Error Code:", e)
    
  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    test_cases = int(input())
    for c in range(test_cases):
        # a, b = map(int, input().split())
        try:
            case = input().split()
            a = int(case[0])
            b = int(case[1])
            answer = a/b
        except ZeroDivisionError as e:
            print(f"Error Code: integer division or modulo by zero")
        except ValueError as e:
            if not case[0].isdigit():
                print(f"Error Code: invalid literal for int() with base 10: '{case[0]}'")
            else:
                print(f"Error Code: invalid literal for int() with base 10: '{case[1]}'")
        else:
            print(int(answer))
    
  • + 0 comments

    It’s always a good idea to handle different types of exceptions so that you can provide more specific error messages or fallback actions, enhancing user experience and code reliability. Bc game register