Question: mystery_value = 5 #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

mystery_value = 5

#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?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Yes your code has a few issues You cant have a try block within another try bl... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!