for k in h: v.append(h.count(k)+1)
This is right in vase v and h are already available. This is not everything in the code.