Here is a simple implementation. You need to keep few things in mind and some prerequisite.
You need to detach the ig from your VPC.
You need to have the ig-id and the vpc-id to continue.
import boto3
ec2 = boto3.resource('ec2')
vpc = ec2.Vpc('vpc-id')
gw = ec2.InternetGateway('igw-id')
vpc.detach_internet_gateway(InternetGatewayId = 'igw-id')
gw.delete()
Hope this helps.