You can view this answer here :
https://www.edureka.co/community/32160/getting-error-while-deleting-my-vpc
Before deleting the VPC successfully you must delete all the dependencies related to the VPC. eg: Internet Gateway, Subnets, Route Tables, etc
The code I used is as follows:
import boto3
ec2 = boto3.resource('ec2')
ec2client = ec2.meta.client
ec2client.delete_vpc(VpcId = 'vpc-01fca2f1bae08f4be')
Once you are done with this, you can run the above code and it works fine