+ 8

Modification of the code is necessary for learning. Numbers in the output are not clear to me !?

https://code.sololearn.com/c03u82cyaR1X/?ref=app

3rd Apr 2018, 10:08 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
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.
3rd Apr 2018, 10:32 PM
Emma