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: 
A solution to get all `p` tags with no child tags.

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

def has_no_tag_children(tag):
    if  type(tag) is bs4.element.Tag: #check if tag
        if tag.name =='p': #check if it is p tag
            if  bs4.element.Tag not in [type(child) for child in tag.children]: # check if has any tag children
                return True
    return False

kids=soup.find_all(has_no_tag_children)
print(kids)

```

Output

```
[<p> hello world </p>]

```
```
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
> 
> 
>