Modify the following code to use exception handling, such that if the user enters in
# a character string, such as "hello", the exception handling code will gracefully handle
# the exception, tell the user what he/she did wrong, and continue to ask the user to
# enter the correct number.
#
# Note: Do not use the isdigit() method with your answer. You should complete this
# assignment using exception handling.
USER_INPUT_MIN = 1
USER_INPUT_MAX = 20
def main() :
answer = 0
while (answer < USER_INPUT_MIN or answer > USER_INPUT_MAX) :
answer = int(input("Enter number: "))
if (answer < USER_INPUT_MIN or answer > USER_INPUT_MAX) :
print("Please enter a number between %d and %d" % (USER_INPUT_MIN, USER_INPUT_MAX))
print("Got the user's answer: ", answer)
main()
Hello Sir, Raheel here.
I've done too many projects in Python having great knowledge about it.
I assure you that I'll deliver your project on time and you can also visit my profile for surety.
I hope you will consider me to do your task Thanks
$25 USD w 1 dzień
4,6 (1 opinia)
2,0
2,0
7 freelancerzy składają oferty o średniej wysokości $45 USD dla tej pracy