Sep-30-2023, 09:47 PM
#WHILE LOOP NOT RETURNING USER INPUT AFTER ZerroDivisionError! HELP! # Using the Modulus operator to find the reminder of any two operands while True: try: divisor = int(input("Enter divisor operand: ")) break except ValueError as e: print(f"{e}; is not an acceptable value ") def modulus(dividend): while True: try: remainder = dividend % divisor qoutient = dividend // divisor if remainder == 0: return f"Operand {dividend} has {remainder} remainder after division by {divisor}, with {qoutient} as the qoutient!" else: print( f"Operand {dividend} has a reminder of {remainder} after division by {divisor} with {qoutient} as the qoutient !" ) except ZeroDivisionError as e: print(f"{e}: {divisor} not divisble by {dividend}") break while True: try: dividend = int(input("Enter dividend operand to get remainder: ")) break except ValueError as e: print(f"{e}; not a valid input") result = modulus(dividend) print(result)
Output:Enter divisor operand: 0
Enter dividend operand to get remainder: 2
integer modulo by zero: 0 not divisble by 2