from bs4 import BeautifulSoup markup = """ Example

This is child of div with id = "parent". Child of "P"

Another Child of div with id = "parent".

Piyush

""" # parsering string to HTML soup = BeautifulSoup(markup, 'html.parser') # finding tag whose child to be deleted div_bs4 = soup.find('div') print(div_bs4) print('-------') # delete the child element div_bs4.clear() new_tag = soup.new_tag('s', attrs={'sk' : 2, 'level' : 5}) div_bs4.append(new_tag) print(div_bs4)