Python program to demonstrate try-except block…
1.Why we need try-except block ?
Ans: Many times the error is coming can be any type syntax,zero division etc. To give protection from attacker and for understanding of non technical person we using try-except block.
2.What is the example of this ?
Ans: The following are some examples :-

After run the code
Here we can easily see that in first line is the problem. So,attacker can easily figure out in which line he/she can stole data.
And also it is hard for normal user to understand what is the program wants to tell.
3.just show how can we solve it ?
Ans : use try-except block~~~……….
a = "hello
try:
print(a)
except SyntaxError:
print("Hello")
Output:
Hello
4.try – except – else block use.
Ans : The else block apply when try block execute.
a = 10/2
try:
print(a)
except ZeroDivisionError:
print("Number is not
divisible by
zero !")
else:
print("The number is
odd number !
")
output :
5
The number is odd number !
●●● If try – exception not catch the error ,the else block applies ●●●
