0

Why 2 is not printed in line 4 in Try, except? In python

try: print(1) print(1+"1"==2) print(2) except TypeError: print(3) else: print(4)

4th Jul 2021, 5:27 AM
Zahed Shaikh
Zahed Shaikh - avatar
2 Réponses
+ 2
because in line 3 you got an error (typeError: cannot add int and str), so program execution jump to except block ^^
4th Jul 2021, 5:31 AM
visph
visph - avatar
+ 1
Thanks visph
4th Jul 2021, 5:32 AM
Zahed Shaikh
Zahed Shaikh - avatar