Here is the simple way of implementing the code for creating a vpc and also subnets inside it.
import boto3
ec2 = boto3.resource('ec2')
vpc = ec2.create_vpc(CidrBlock='10.0.0.0/16')
vpc.create_tags(Tags=[{"Key":"TestVPC","Value":"default_vpc"}])
vpc.wait_until_available()
print(vpc.id)
subnet = ec2.create_subnet(CidrBlock = '10.0.2.0/24', VpcId= vpc.id)
print(subnet.id)
Hope this will help