In the following code, the comment shows the position where I want to stop the execution.

```
about_pet=input("Enter a sentence about pet: ")
if 'dog' in about_pet:
    if not 'cat' in about_pet:
        print("Ah, a dog")
    elif 'cat' in about_pet:
        print('Dog and Cat')
        # I want to stop execution here.
if 'cat' in about_pet:
    print('Meow!! Meow!!')

```

[output of above code](https://i.stack.imgur.com/2Vdvq.png)

I have tried this:

```
import sys
about_pet=input("Enter a sentence about pet: ")
if 'dog' in about_pet:
    if not 'cat' in about_pet:
        print("Ah, a dog")
    elif 'cat' in about_pet:
        print('Dog and Cat')
        exit()
if 'cat' in about_pet:
    print('Meow!! Meow!!')

```

But the above code stops the kernel and it gets restarted on clicking ok.
[See Image](https://i.stack.imgur.com/9nRSd.png)

The break condition is showing error that it's not inside loop.