I have to solve a task that reads:
Write a procedure def trialAndError(), which calls an already defined function process(). The function should
- output 'Succeeded' if no error was raised in the process() function.
- output 'TypeError' caught if the process() function raised a TypeError
- output 'ValueError' caught if the process() function raised a ValueError
- output 'ZeroDivisionError' caught if the process() function raised a ZeroDivisionError
This exercise is on some kind of Python program aimed to help students learn Python, so I have to run the code in this program.
This is my code: link removed code added below ,
- Code: Select all
print "TypeError caught"
print "ValueError caught"
print "ZeroDivisionError caught"
# your code goes here
but it's not quite right and I have no idea what I'm doing wrong. When I'm running it in pyCharm, it works fine and prints Succeeded. However, when I run it in the learning program I get all sorts of errors. I think that the program is randomizing errors when the code is executed, and if my code would work it would print any of the exceptions, but it doesn't. I think that's also why it works in pyCharm, because there are no random errors there. Bad explanation but I hope you understood... Any help would be appreciated!!