+ 1

Why variable / 2 is not printing?

try: variable = 10 print(variable + "hello") print(variable / 2) except ZeroDivisionError: print("Divided by zero") except (ValueError, TypeError): print("Error occurred")

3rd Nov 2017, 3:11 PM
Дмитрий Пилипончик
Дмитрий Пилипончик - avatar
3 Answers
+ 5
It's not printing because you forgot to remove or correct the line above it that's causing the error. ;) CHANGE TO: variable = 10 print(str(variable) + "hello") print(variable / 2) OUTPUT: 10hello 5.0
3rd Nov 2017, 3:21 PM
AgentSmith
0
Variable + hello is a type error, its ok, but variable / 2 == 5 right??
3rd Nov 2017, 3:13 PM
Дмитрий Пилипончик
Дмитрий Пилипончик - avatar
0
Ok i get it, because code is stoping on variable + hello line
3rd Nov 2017, 3:18 PM
Дмитрий Пилипончик
Дмитрий Пилипончик - avatar