Why do we need else

According to the video else is executed if there is no exceptions. But why can’t we just make the contents of else as a part of try block itself and write it in the bottom of try block so according to the sequence of execution the program would reach that part of code if exceptions are not encountered previously

Hey @Vignesh-0510, that’s a good question. Yes you are right that we can do the work done by else block in the try block itself right ? Now there’s one case which can be covered by the use of else block only. To see that case I would request you to read this link.

I hope it helps you resolve your doubt :+1:
Happy Learning :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.