Question: NEED HELP WITH THIS IN PYTHON #Re-factor the code below that attempts to compute a reciprocal so that it keeps prompting the user for a
NEED HELP WITH THIS IN PYTHON
#Re-factor the code below that attempts to compute a reciprocal so that it keeps prompting the user for a number repeatedly until the user successfully enters a valid number. If the user enters 0, the program should print that zero does not have a reciprocal, then terminate. # YOUR CODE HERE raise NotImplementedError() try: x = float(input("Enter a number: ")) print("The reciprocal of your number is", 1/x) except ValueError: print("You did not enter a valid number.") except ZeroDivisionError: print("Zero does not have a reciprocal") except: print("something else went wrong.")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
