mystery_value = 5 #Write program to divides mystery_value by mystery_value #and prints the result. If that operation
Fantastic news! We've Found the answer you've been seeking!
Question:
#Write program to divides mystery_value by mystery_value
#and prints the result. If that operation results in an
#error, divide mystery_value by (mystery_value + 5) and then
#print the result. If that still fails, multiply mystery_value
#by 5 and print the result. You may assume one of those three
#things will work.
#
#You may not use any conditionals.
#
#Hint: You're going to want to test one try/except structure
#inside another! Think carefully about whether the second
#one should go inside the try block or the except block.
#Added my code here:
try:
result=mystery_value/mystery_value
return result
try:
except:
result=mystery_value/(mystery_value+5)
return result
except:
result=mystery_value*5
return result
#did I set this up wrong?
Related Book For
Posted Date: