+ 8
Modification of the code is necessary for learning. Numbers in the output are not clear to me !?
1 Réponse
+ 2
try:, 'tries' to execute some code. If an exception occurs, the code is not executed, but instead the except: clause is executed.
If no exception occurs, then the else clause is executed.
1 divided by zero gives a divide by zero exception, as 0 goes into 1 an infinite amount of times!
Therefore the first and last bits of code, the try: and else: clauses are executed, but in the second bit of code, only the except: clause is executed.