Jun-07-2021, 09:19 PM
Quote:no that code not work requirement is if num2 = 0 (divisor is zero), calculator should prompt user again for num2 until it is non zero and displays correct output (num1 /num2) and then exit the loop with op = (please choose ooperator or q to quit)
You haven't tried it, that is exactly what deanhystad's code does.
just added a print statement at end:
num2 = 0 while num2 == 0: num2 = float(input('\nenter a non-zero divisor ')) print(f"num2: {num2}")
Output:enter a non-zero divisor 0
enter a non-zero divisor 0
enter a non-zero divisor 12
num2: 12.0