Sep-30-2023, 09:02 PM
(This post was last modified: Sep-30-2023, 09:06 PM by deanhystad.)
#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: return f"Operand {dividend} has a reminder of {remainder} after division by {divisor} with {qoutient} as the qoutient !" except ZeroDivisionError as e: return f"{e}:not divisble" 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)
deanhystad write Sep-30-2023, 09:06 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.