Question: Some `<p></p>` tags has `<img>` tag and `<h4>` tag, but I want just those `<p>` tag which has no siblings tags in it just contents.

```
 <p> <img src="any url"/> </p>     <p> hello world </p>

```

I want `<p>` tag which has no `<img>` tag using beautiful soup

Answer: 
Assuming BeautifulSoup 4.7+, you should be able to do this:

```py
import bs4
html="""<p> <img src="any url"/> </p>     <p> hello world </p>"""
soup=bs4.BeautifulSoup(html,"html.parser")

kids=soup.select("p:not(:has(*))")
print(kids)

```
```
from bs4 import BeautifulSoup

txt = """
<p> <img src="any url"/> </p>     <p> hello world </p>
"""

soup = BeautifulSoup(txt)

for node in soup.findAll('p'):
    print(' '.join(node.findAll(text=True, recursive = False)))

```

OUTPUT:

> 
> hello world
> 
> 
>