0

Can't we use both finally and raise in the same block of code?

I'm unable to use both finally and raise at a time E.g: try: print(2/0) except: pass raise ZeroDivisionError finally: print('last word') For this I'm facing Syntax Error.

9th Apr 2019, 12:59 PM
paperinflames
paperinflames - avatar
2 Antworten
+ 4
raise ZeroDivisionError is not indented. That means that the try-block is already over. So your finally has no relation to anything, because it finds no try-block before it.
9th Apr 2019, 1:06 PM
HonFu
HonFu - avatar
0
What are you trying to achieve?
9th Apr 2019, 1:29 PM
Anna
Anna - avatar